Reimplement as a tokenizer with GFM parity
This commit is contained in:
+9
-6
@@ -1,6 +1,8 @@
|
||||
import { ribbit } from './setup';
|
||||
|
||||
const r = ribbit();
|
||||
const lib = ribbit();
|
||||
|
||||
const spacePattern = / /g;
|
||||
|
||||
const macros = [
|
||||
{
|
||||
@@ -11,7 +13,7 @@ const macros = [
|
||||
name: 'npc',
|
||||
toHTML: ({ keywords }: any) => {
|
||||
const name = keywords.join(' ');
|
||||
return '<a href="/NPC/' + name.replace(/ /g, '') + '">' + name + '</a>';
|
||||
return '<a href="/NPC/' + name.replace(spacePattern, '') + '">' + name + '</a>';
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -24,9 +26,9 @@ const macros = [
|
||||
},
|
||||
];
|
||||
|
||||
const h = new r.HopDown({ macros });
|
||||
const H = (md: string) => h.toHTML(md);
|
||||
const M = (html: string) => h.toMarkdown(html);
|
||||
const converter = new lib.HopDown({ macros });
|
||||
const H = (md: string) => converter.toHTML(md);
|
||||
const M = (html: string) => converter.toMarkdown(html);
|
||||
|
||||
describe('Macros', () => {
|
||||
describe('self-closing', () => {
|
||||
@@ -61,7 +63,8 @@ describe('Macros', () => {
|
||||
it('keyword stripped from data-keywords', () => {
|
||||
const html = H('@style(box verbatim\ncontent\n)');
|
||||
expect(html).toContain('data-keywords="box"');
|
||||
expect(html).not.toMatch(/data-keywords="[^"]*verbatim/);
|
||||
const verbatimKeywordPattern = /data-keywords="[^"]*verbatim/;
|
||||
expect(html).not.toMatch(verbatimKeywordPattern);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user