test(backend): Testen voor DatabaseLearningObjectProvider.getLearningObjectHTML toegevoegd.
Hierbij optredende problemen ook opgelost.
This commit is contained in:
parent
a3b995393b
commit
91e3b5ad91
15 changed files with 103 additions and 60 deletions
|
@ -2,14 +2,14 @@
|
|||
* Based on https://github.com/dwengovzw/Learning-Object-Repository/blob/main/app/processors/markdown/markdown_processor.js
|
||||
*/
|
||||
|
||||
import {marked} from 'marked'
|
||||
import Processor from '../processor.js';
|
||||
import {marked} from 'marked';
|
||||
import InlineImageProcessor from '../image/inline-image-processor.js';
|
||||
import {DwengoContentType} from "../content-type";
|
||||
import {ProcessingError} from "../processing-error";
|
||||
import dwengoMarkedRenderer from "./dwengo-marked-renderer";
|
||||
import {StringProcessor} from "../string-processor";
|
||||
import {ProcessingError} from "../processing-error";
|
||||
|
||||
class MarkdownProcessor extends Processor<string> {
|
||||
class MarkdownProcessor extends StringProcessor {
|
||||
constructor() {
|
||||
super(DwengoContentType.TEXT_MARKDOWN);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ class MarkdownProcessor extends Processor<string> {
|
|||
override renderFn(mdText: string) {
|
||||
let html = "";
|
||||
try {
|
||||
mdText = this.replaceLinks(mdText); // Replace html image links with path based on metadata
|
||||
marked.use({renderer: dwengoMarkedRenderer});
|
||||
html = marked(mdText, {async: false});
|
||||
html = this.replaceLinks(html); // Replace html image links path
|
||||
} catch (e: any) {
|
||||
throw new ProcessingError(e.message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue