diff --git a/README.md b/README.md index 407589c..f7abc90 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ a [Marked.js](https://marked.js.org) custom extension for [Misskey-flavored Markdown](https://github.com/misskey-dev/mfm.js/blob/develop/docs/syntax.md). this is a reimplementation of [the original MFM parser](https://github.com/misskey-dev/mfm.js/blob/develop/docs/syntax.md), which was written from the ground up using PEG.js instead of as an extension of CommonMark, and therefore was not up to spec. +this extension is mostly compatible with the original, except it only implements `$[tags]`. mentions, hashtags and the `search` markup are out of scope. ## usage @@ -11,5 +12,5 @@ const markedMfm = require('marked-mfm') marked.use(markedMfm) marked.parse('$[x2 beeg text]') -//

beeg text

+//

beeg text

``` diff --git a/lib/index.umd.js b/lib/index.umd.js index b4cea17..352f068 100644 --- a/lib/index.umd.js +++ b/lib/index.umd.js @@ -147,32 +147,6 @@ return "$[" + token.tag + " " + this.parser.parseInline(token.tokens) + "]"; } - }, { - name: 'mfmSearch', - level: 'inline', - start: function start(src) { - var _src$match2; - - return (_src$match2 = src.match(/(?<=^|
).+ search(?=$|
)/)) == null ? void 0 : _src$match2.index; - }, - tokenizer: function tokenizer(src, tokens) { - var rule = /^(?!.*
)(.+) search(?=$|
)/; - var match = rule.exec(src); - - if (match) { - var token = { - type: 'mfmSearch', - raw: match[0], - query: match[1].trim(), - tokens: [] - }; - this.lexer.inline(token.text, token.tokens); - return token; - } - }, - renderer: function renderer(token) { - return "" + token.raw + ""; - } }] }; diff --git a/package.json b/package.json index c7566f4..64bf474 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marked-mfm", - "version": "0.3.2", + "version": "0.4.0", "description": "Marked.js extension for Misskey-flavored Markdown", "main": "./src/index.js", "browser": "./lib/index.umd.js", diff --git a/src/index.js b/src/index.js index c899aa3..f4d337b 100644 --- a/src/index.js +++ b/src/index.js @@ -50,27 +50,5 @@ export default { return `$[${token.tag} ${this.parser.parseInline(token.tokens)}]` }, }, - { - name: 'mfmSearch', - level: 'inline', - start (src) { return src.match(/(?<=^|
).+ search(?=$|
)/)?.index }, - tokenizer (src, tokens) { - const rule = /^(?!.*
)(.+) search(?=$|
)/ - const match = rule.exec(src) - if (match) { - const token = { - type: 'mfmSearch', - raw: match[0], - query: match[1].trim(), - tokens: [], - } - this.lexer.inline(token.text, token.tokens) - return token - } - }, - renderer (token) { - return `${token.raw}` - }, - }, ], } diff --git a/test/index.test.js b/test/index.test.js index 2b48178..35b11bf 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -41,9 +41,4 @@ describe('marked-mfm', () => { marked.use(markedMfm) expect(marked('$[spin.alternate,speed=0.5s test]')).toBe('

test

\n') }) - - test('search', () => { - marked.use(markedMfm) - expect(marked('syuilo thighs search')).toBe('

syuilo thighs search

\n') - }) })