Add new text syntax

And some fixes
This commit is contained in:
syuilo
2018-04-19 15:05:39 +09:00
parent f6a041559f
commit 7a270275ef
6 changed files with 56 additions and 2 deletions

View File

@@ -54,6 +54,12 @@ const handlers = {
document.body.appendChild(blockquote);
},
title({ document }, { title }) {
const h1 = document.createElement('h1');
h1.textContent = title;
document.body.appendChild(h1);
},
text({ document }, { content }) {
for (const text of content.split('\n')) {
const node = document.createTextNode(text);

View File

@@ -0,0 +1,14 @@
/**
* Title
*/
module.exports = text => {
const match = text.match(/^【(.+?)】\n/);
if (!match) return null;
const title = match[0];
return {
type: 'title',
content: title,
title: title.substr(1, title.length - 3)
};
};

View File

@@ -4,6 +4,7 @@
const elements = [
require('./elements/bold'),
require('./elements/title'),
require('./elements/url'),
require('./elements/link'),
require('./elements/mention'),