@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
37 lines • 1.21 kB
JavaScript
import { MarkUp, MarkupType, TokenType } from './markup';
export class WhatsApp extends MarkUp {
constructor() {
super(MarkupType.WHATSAPP);
this.type = MarkupType.WHATSAPP;
this.STRONG = '*';
this.EMPHASIS = '_';
}
parse(_txt) {
throw new Error('WhatsApp.parse not implemented');
}
renderToken(token) {
if (token.items) {
return token.items.map(item => this.render(item.tokens)).join('\n');
}
const inner = token.tokens
? this.render(token.tokens, '')
: token.text || '';
if (token.type == TokenType.STRONG) {
return `${this.STRONG}${inner}${this.STRONG}`;
}
if (token.type == TokenType.EMPHASIS) {
return `${this.EMPHASIS}${inner}${this.EMPHASIS}`;
}
return inner || '';
}
wrapWithInline(input, inlineType) {
if (inlineType === TokenType.EMPHASIS) {
return `_${input}_`;
}
if (inlineType === TokenType.STRONG) {
return `*${input}*`;
}
throw new Error(`wrapWithInline does not support inline ${inlineType}`);
}
}
//# sourceMappingURL=whatsapp.js.map