Get commonmark blockquotes on-theme.

This commit is contained in:
Cory McWilliams 2024-04-11 01:30:49 +01:00
parent a421604ed5
commit a7922ff44e
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🐌",
"previous": "&sR39JhvUCRlOv7hdEWV81RWWkyoPGLg6u4w+BfqUE9s=.sha256"
"previous": "&hKBq89Q1oOiSK8ZtiA67MciAaMNCRK5CuYtOeoX94qU=.sha256"
}

View File

@ -1,7 +1,6 @@
import {css} from './lit-all.min.js';
const tf = css`
img {
max-width: min(640px, 100%);
max-height: min(480px, auto);
@ -44,7 +43,6 @@ const tf = css`
}
blockquote {
background-color: #607d8b;
border-left: 4px solid #fff;
padding: 8px;
padding-left: 12px;

View File

@ -60,10 +60,19 @@ function image(node, entering) {
}
}
function attrs(node) {
let result = commonmark.HtmlRenderer.prototype.attrs.bind(this)(node);
if (node.type == 'block_quote') {
result.push(['class', 'w3-theme-d1']);
}
return result;
}
export function markdown(md) {
let reader = new commonmark.Parser({safe: true});
let writer = new commonmark.HtmlRenderer();
writer.image = image;
writer.attrs = attrs;
let parsed = reader.parse(md || '');
parsed = hashtagify.transform(parsed);
let walker = parsed.walker();