summaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-19 15:05:39 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-19 15:05:39 +0900
commit7a270275efcb49c182db5db73ce10c65ba6ad3ff (patch)
tree4eb87d011ec38b23ed123d713b6640cc4ac9e2ea /src/text
parentAdd doc (diff)
downloadsharkey-7a270275efcb49c182db5db73ce10c65ba6ad3ff.tar.gz
sharkey-7a270275efcb49c182db5db73ce10c65ba6ad3ff.tar.bz2
sharkey-7a270275efcb49c182db5db73ce10c65ba6ad3ff.zip
Add new text syntax
And some fixes
Diffstat (limited to 'src/text')
-rw-r--r--src/text/html.ts6
-rw-r--r--src/text/parse/elements/title.ts14
-rw-r--r--src/text/parse/index.ts1
3 files changed, 21 insertions, 0 deletions
diff --git a/src/text/html.ts b/src/text/html.ts
index 797f3b3f33..e2db2457c1 100644
--- a/src/text/html.ts
+++ b/src/text/html.ts
@@ -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);
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'),