From 7a270275efcb49c182db5db73ce10c65ba6ad3ff Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 19 Apr 2018 15:05:39 +0900 Subject: Add new text syntax And some fixes --- src/text/parse/elements/title.ts | 14 ++++++++++++++ src/text/parse/index.ts | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/text/parse/elements/title.ts (limited to 'src/text/parse') diff --git a/src/text/parse/elements/title.ts b/src/text/parse/elements/title.ts new file mode 100644 index 0000000000..9f4708f5d6 --- /dev/null +++ b/src/text/parse/elements/title.ts @@ -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) + }; +}; diff --git a/src/text/parse/index.ts b/src/text/parse/index.ts index b958da81b0..4bcedd22ac 100644 --- a/src/text/parse/index.ts +++ b/src/text/parse/index.ts @@ -4,6 +4,7 @@ const elements = [ require('./elements/bold'), + require('./elements/title'), require('./elements/url'), require('./elements/link'), require('./elements/mention'), -- cgit v1.2.3-freya