@botonic/plugin-contentful
Version:
Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet
45 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Markdown = void 0;
const tslib_1 = require("tslib");
const marked = tslib_1.__importStar(require("marked"));
const markup_1 = require("./markup");
/**
* marked's intex.ts does not include these types (though they work): del, strong, em
*/
class Markdown extends markup_1.MarkUp {
constructor(flavour) {
super(flavour);
switch (flavour) {
case markup_1.MarkupType.MARKDOWN:
this.options = {};
break;
case markup_1.MarkupType.GITHUB:
case markup_1.MarkupType.CONTENTFUL:
this.options = { gfm: true };
break;
default:
throw Error(`Invalid markdown flavour: ${flavour}`);
}
}
parse(txt) {
// cannot cache Lexer because it would accumulate the tokens
return marked.lexer(txt);
}
renderToken(_token) {
throw new Error('Not implemented');
}
wrapWithInline(input, inlineType) {
// emphasis & strong cannot have internal spaces
input = input.trim();
if (inlineType === markup_1.TokenType.EMPHASIS) {
return `_${input}_`;
}
if (inlineType === markup_1.TokenType.STRONG) {
return `**${input}**`;
}
throw new Error(`wrapWithInline does not support inline ${inlineType}`);
}
}
exports.Markdown = Markdown;
//# sourceMappingURL=markdown.js.map