Compare commits

...

2 Commits

Author SHA1 Message Date
1dcc58c4b2
0.2.4 2023-05-18 21:38:06 -07:00
78f99afef0
do not render anchors to nowhere 2023-05-18 21:38:05 -07:00
3 changed files with 10 additions and 12 deletions

4
package-lock.json generated
View File

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

View File

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

View File

@ -30,16 +30,14 @@ export function create_renderer(opts: MarkdownOptions) {
function heading(renderer: marked.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) {
let { text, id, html_attrs } = parse_attributes(raw); let { text, id, html_attrs } = parse_attributes(raw);
if (id) {
text += `\n<a class="heading-anchor" href="#${id}">`
+ `\n\t\t${icons.link}`
+ `\n\t\t<span style="display: none">Section titled ${text}</span>`
+ `\n\t</a>`;
}
return ` return `\n<h${level} ${html_attrs.join(' ')}>\n\t${text}\n</h${level}>`;
<h${level} ${html_attrs.join(' ')}>
${text}
<a class="heading-anchor" href="#${id}">
${icons.link}
<span style="display: none">Section titled ${text}</span>
</a>
</h${level}>
`;
}; };
} }