Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove heading extesions #33

Closed
kazk opened this issue Oct 21, 2021 · 0 comments · Fixed by #46
Closed

Remove heading extesions #33

kazk opened this issue Oct 21, 2021 · 0 comments · Fixed by #46
Assignees
Labels
Milestone

Comments

@kazk
Copy link
Member

kazk commented Oct 21, 2021

Ids are handled by marked, with better implementation using unique slugs. I don't know if we need icon support, but it can be handled with overrides (#31).

function setupHeader(renderer, options, result) {
// heading extensions
renderer.heading = function (text, level) {
// you can set icons via icon::name
const icon = text.match(/icon::([a-z-]*)/);
let attributes = '';
if (icon) {
// indicate that this icon has been used
result.icons[icon[1]] = true;
attributes = ` class="${options.iconClassPrefix}${icon[1]}"`;
text = text.replace(/icon::[a-z-]*/, '');
}
// we track headers 1 - 4 and add ids to them so that we can link to them later if we want to
if (level < 5) {
const header = result.headers[`h${level}`];
const index = header.length;
attributes += ` id="h${level}_${index}"`;
header.push(text);
}
return `<h${level}${attributes}>${text}</h${level}>`;
}
}

@kazk kazk added this to the v1 milestone Oct 21, 2021
@kazk kazk self-assigned this Oct 24, 2021
@kazk kazk closed this as completed in #46 Oct 26, 2021
@kazk kazk added the trim label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant