Remove search
ci/woodpecker/tag/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details

fuck search
This commit is contained in:
Sol Fisher Romanoff 2022-07-12 20:29:43 +03:00
parent c748bacc0f
commit 4d885754fd
Signed by: nbsp
GPG Key ID: 9D3F2B64F2341B62
5 changed files with 3 additions and 55 deletions

View File

@ -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]')
// <p><span class="_mfm_x2_" >beeg text</span></p>
// <p><span class="mfm _mfm_x2_" >beeg text</span></p>
```

View File

@ -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(/(?<=^|<br>).+ search(?=$|<br>)/)) == null ? void 0 : _src$match2.index;
},
tokenizer: function tokenizer(src, tokens) {
var rule = /^(?!.*<br>)(.+) search(?=$|<br>)/;
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 "<a href=\"https://google.com/search?q=" + token.query + "\" class=\"mfm _mfm_search_\">" + token.raw + "</a>";
}
}]
};

View File

@ -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",

View File

@ -50,27 +50,5 @@ export default {
return `$[${token.tag} ${this.parser.parseInline(token.tokens)}]`
},
},
{
name: 'mfmSearch',
level: 'inline',
start (src) { return src.match(/(?<=^|<br>).+ search(?=$|<br>)/)?.index },
tokenizer (src, tokens) {
const rule = /^(?!.*<br>)(.+) search(?=$|<br>)/
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 `<a href="https://google.com/search?q=${token.query}" class="mfm _mfm_search_">${token.raw}</a>`
},
},
],
}

View File

@ -41,9 +41,4 @@ describe('marked-mfm', () => {
marked.use(markedMfm)
expect(marked('$[spin.alternate,speed=0.5s test]')).toBe('<p><span class="mfm _mfm_spin_" data-alternate data-speed="0.5s">test</span></p>\n')
})
test('search', () => {
marked.use(markedMfm)
expect(marked('syuilo thighs search')).toBe('<p><a href="https://google.com/search?q=syuilo thighs" class="mfm _mfm_search_">syuilo thighs search</a></p>\n')
})
})