Compare commits

..

No commits in common. "704447f7c0d4f8e0aafebc810bd7670461eb467a" and "4274045fca00325fdc600b442045b66e78feb64e" have entirely different histories.

4 changed files with 9 additions and 6 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@doc-utils/markdown2html",
"version": "0.2.1",
"version": "0.2.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@doc-utils/markdown2html",
"version": "0.2.1",
"version": "0.2.0",
"dependencies": {
"bytefield-svg": "^1.6.1",
"dompurify": "^2.3.6",

View File

@ -1,6 +1,6 @@
{
"name": "@doc-utils/markdown2html",
"version": "0.2.1",
"version": "0.2.0",
"publishConfig": {
"registry": "https://gitea.home.jbrumond.me/api/packages/doc-utils/npm/"
},

View File

@ -30,8 +30,6 @@ export async function render_markdown_to_html(markdown: string, options: Markdow
async: true,
breaks: options.breaks || false,
renderer: create_renderer(options),
mangle: false,
headerIds: false,
};
marked.use({

View File

@ -28,8 +28,13 @@ export function create_renderer(opts: MarkdownOptions) {
}
function heading(renderer: marked.Renderer, opts: MarkdownOptions) {
return function(orig_text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string) {
return function(orig_text: string, level: 1 | 2 | 3 | 4 | 5 | 6, raw: string, slugger) {
let { text, id, html_attrs } = parse_attributes(raw);
if (! id) {
id = slugger.slug(text);
html_attrs.push(`id="${id}"`);
}
return `
<h${level} ${html_attrs.join(' ')}>