2019-07-14 17:00:02 +02:00
|
|
|
const markdownUtils = require('lib/markdownUtils');
|
|
|
|
const htmlUtils = require('lib/htmlUtils');
|
|
|
|
const Note = require('lib/models/Note');
|
|
|
|
|
|
|
|
class MarkupLanguageUtils {
|
|
|
|
lib_(language) {
|
|
|
|
if (language === Note.MARKUP_LANGUAGE_HTML) return htmlUtils;
|
|
|
|
if (language === Note.MARKUP_LANGUAGE_MARKDOWN) return markdownUtils;
|
2019-09-19 23:51:18 +02:00
|
|
|
throw new Error(`Unsupported markup language: ${language}`);
|
2019-07-14 17:00:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extractImageUrls(language, text) {
|
|
|
|
return this.lib_(language).extractImageUrls(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const markupLanguageUtils = new MarkupLanguageUtils();
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
module.exports = markupLanguageUtils;
|