4 Commits

Author SHA1 Message Date
ae7b491107 0.1.17 2023-05-12 14:59:49 -07:00
8599460702 whitelist rdfa tags/attrs in html sanitizer 2023-05-12 14:59:45 -07:00
fb52d31090 0.1.16 2023-05-12 14:54:12 -07:00
859064f00b add rdfa for breadcrumbs 2023-05-12 14:54:05 -07:00
4 changed files with 14 additions and 8 deletions

4
package-lock.json generated
View File

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

View File

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

View File

@@ -41,16 +41,19 @@ export function breadcrumb_nav_ext(renderer: marked.Renderer, opts: MarkdownOpti
},
renderer(token: BreadcrumbNavToken) {
return `<nav aria-label="breadcrumbs" ${token.attrs.html_attrs.join(' ')}>\n`
+ `\t<ol>\n`
+ `\t<ol typeof="https://schema.org/BreadcrumbList">\n`
+ '\t\t'
+ token.items.map((tokens, index) =>{
let item = '<li>';
let item = '<li property="itemListElement" typeof="https://schema.org/ListItem">\n';
if (index) {
item += '<span class="separator" aria-hidden="true">/</span> ';
item += '\t\t\t<span class="separator" aria-hidden="true">/</span>\n';
}
return item + this.parser.parseInline(tokens, renderer) + '</li>';
item += `\t\t\t<span property="name">${this.parser.parseInline(tokens, renderer)}</span>\n`;
item += `\t\t\t<meta property="position" content="${index + 1}">\n`;
return item + + '\t\t</li>';
}).join('\n\t\t')
+ '\n'
+ `\t</ol>\n`

View File

@@ -8,6 +8,9 @@ export function sanitize_html(html: string, custom_elements?: CustomElementHandl
const { window } = new JSDOM('');
const dom_purify = createDOMPurify(window as any as Window);
return dom_purify.sanitize(html, {
CUSTOM_ELEMENT_HANDLING: custom_elements
CUSTOM_ELEMENT_HANDLING: custom_elements,
ALLOWED_TAGS: ['meta'],
ALLOWED_ATTR: ['typeof', 'property', 'content'],
ADD_URI_SAFE_ATTR: ['typeof']
});
}