From a7922ff44e863a6624ac6cdc59c6162ba79c0f0a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 11 Apr 2024 01:30:49 +0100 Subject: [PATCH] Get commonmark blockquotes on-theme. --- apps/ssb.json | 2 +- apps/ssb/tf-styles.js | 2 -- apps/ssb/tf-utils.js | 9 +++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 41c7a9e2..39573215 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🐌", - "previous": "&sR39JhvUCRlOv7hdEWV81RWWkyoPGLg6u4w+BfqUE9s=.sha256" + "previous": "&hKBq89Q1oOiSK8ZtiA67MciAaMNCRK5CuYtOeoX94qU=.sha256" } diff --git a/apps/ssb/tf-styles.js b/apps/ssb/tf-styles.js index 4db41413..c439d724 100644 --- a/apps/ssb/tf-styles.js +++ b/apps/ssb/tf-styles.js @@ -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; diff --git a/apps/ssb/tf-utils.js b/apps/ssb/tf-utils.js index 6b0e280a..088d0b9b 100644 --- a/apps/ssb/tf-utils.js +++ b/apps/ssb/tf-utils.js @@ -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();