diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-31 19:53:30 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-31 20:30:28 +0900 |
| commit | 7da60a0147116130a94274e4a20ae54dd7d59dea (patch) | |
| tree | 442514d76f90ede80906659b14d5f7bbc531d32a /src/common/text/parse/elements/inline-code.ts | |
| parent | Set empty array instead of null to mediaIds property of posts (diff) | |
| download | sharkey-7da60a0147116130a94274e4a20ae54dd7d59dea.tar.gz sharkey-7da60a0147116130a94274e4a20ae54dd7d59dea.tar.bz2 sharkey-7da60a0147116130a94274e4a20ae54dd7d59dea.zip | |
Store texts as HTML
Diffstat (limited to 'src/common/text/parse/elements/inline-code.ts')
| -rw-r--r-- | src/common/text/parse/elements/inline-code.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/text/parse/elements/inline-code.ts b/src/common/text/parse/elements/inline-code.ts new file mode 100644 index 0000000000..9f9ef51a2b --- /dev/null +++ b/src/common/text/parse/elements/inline-code.ts @@ -0,0 +1,17 @@ +/** + * Code (inline) + */ + +import genHtml from '../core/syntax-highlighter'; + +module.exports = text => { + const match = text.match(/^`(.+?)`/); + if (!match) return null; + const code = match[0]; + return { + type: 'inline-code', + content: code, + code: code.substr(1, code.length - 2).trim(), + html: genHtml(code.substr(1, code.length - 2).trim()) + }; +}; |