Fix search not working properly

This commit is contained in:
Sol Fisher Romanoff 2022-07-09 14:27:23 +03:00
parent 3e9141c633
commit 8e4cb2639b
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
3 changed files with 7 additions and 7 deletions

View file

@ -145,14 +145,14 @@
}
}, {
name: 'mfmSearch',
level: 'block',
level: 'inline',
start: function start(src) {
var _src$match2;
return (_src$match2 = src.match(/[^\n]+ search/)) == null ? void 0 : _src$match2.index;
return (_src$match2 = src.match(/(?<=^|\n).+ search(?=$|\n)/)) == null ? void 0 : _src$match2.index;
},
tokenizer: function tokenizer(src, tokens) {
var rule = /^([^\n]+) search$/;
var rule = /^(.+) search(?=$|\n)/;
var match = rule.exec(src);
if (match) {

View file

@ -49,10 +49,10 @@ export default {
},
{
name: 'mfmSearch',
level: 'block',
start (src) { return src.match(/[^\n]+ search/)?.index },
level: 'inline',
start (src) { return src.match(/(?<=^|\n).+ search(?=$|\n)/)?.index },
tokenizer (src, tokens) {
const rule = /^([^\n]+) search$/
const rule = /^(.+) search(?=$|\n)/
const match = rule.exec(src)
if (match) {
const token = {

View file

@ -44,6 +44,6 @@ describe('marked-mfm', () => {
test('search', () => {
marked.use(markedMfm)
expect(marked('syuilo thighs search')).toBe('<a href="https://google.com/search?q=syuilo thighs" class="_mfm_search_">syuilo thighs search</a>')
expect(marked('syuilo thighs search')).toBe('<p><a href="https://google.com/search?q=syuilo thighs" class="_mfm_search_">syuilo thighs search</a></p>\n')
})
})