Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 src/Lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class _Lexer<ParserOutput = string, RendererOutput = string> {
href: token.href,
title: token.title,
};
tokens.push(token);
UziTech marked this conversation as resolved.
Show resolved Hide resolved
}
continue;
}
Expand Down
6 changes: 5 additions & 1 deletion 6 src/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class _Parser<ParserOutput = string, RendererOutput = string> {
if (this.options.extensions?.renderers?.[anyToken.type]) {
const genericToken = anyToken as Tokens.Generic;
const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'def', 'paragraph', 'text'].includes(genericToken.type)) {
out += ret || '';
continue;
}
Expand Down Expand Up @@ -90,6 +90,10 @@ export class _Parser<ParserOutput = string, RendererOutput = string> {
out += this.renderer.html(token);
continue;
}
case 'def': {
out += this.renderer.def(token);
continue;
}
case 'paragraph': {
out += this.renderer.paragraph(token);
continue;
Expand Down
4 changes: 4 additions & 0 deletions 4 src/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class _Renderer<ParserOutput = string, RendererOutput = string> {
return text as RendererOutput;
}

def(token: Tokens.Def): RendererOutput {
return '' as RendererOutput;
}

heading({ tokens, depth }: Tokens.Heading): RendererOutput {
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n` as RendererOutput;
}
Expand Down
18 changes: 18 additions & 0 deletions 18 test/unit/Lexer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,15 @@ paragraph
links: {
link: { href: 'https://example.com', title: undefined },
},
tokens: [
{
type: 'def',
raw: '[link]: https://example.com',
tag: 'link',
href: 'https://example.com',
title: undefined,
},
],
});
});

Expand All @@ -1340,6 +1349,15 @@ paragraph
links: {
link: { href: 'https://example.com', title: 'title' },
},
tokens: [
{
type: 'def',
raw: '[link]: https://example.com "title"',
tag: 'link',
href: 'https://example.com',
title: 'title',
},
],
});
});
});
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.