Fix search not working properly
This commit is contained in:
parent
3e9141c633
commit
8e4cb2639b
3 changed files with 7 additions and 7 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue