refactor(backend): Types
This commit is contained in:
parent
6ad7fbf208
commit
25f9eb2af2
31 changed files with 92 additions and 86 deletions
|
@ -8,6 +8,7 @@ import { DwengoContentType } from '../content-type.js';
|
|||
import dwengoMarkedRenderer from './dwengo-marked-renderer.js';
|
||||
import { StringProcessor } from '../string-processor.js';
|
||||
import { ProcessingError } from '../processing-error.js';
|
||||
import { YAMLException } from 'js-yaml';
|
||||
|
||||
class MarkdownProcessor extends StringProcessor {
|
||||
constructor() {
|
||||
|
@ -19,8 +20,12 @@ class MarkdownProcessor extends StringProcessor {
|
|||
marked.use({ renderer: dwengoMarkedRenderer });
|
||||
const html = marked(mdText, { async: false });
|
||||
return this.replaceLinks(html); // Replace html image links path
|
||||
} catch (e: any) {
|
||||
throw new ProcessingError(e.message);
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof YAMLException) {
|
||||
throw new ProcessingError(e.message);
|
||||
}
|
||||
|
||||
throw new ProcessingError('Unknown error while processing markdown: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue