diff --git a/apps/ssb/tf-styles.js b/apps/ssb/tf-styles.js
index 7522007b..e29ba61c 100644
--- a/apps/ssb/tf-styles.js
+++ b/apps/ssb/tf-styles.js
@@ -34,12 +34,9 @@ const tf = css`
content: ' ±';
}
- code {
- background-color: #444;
- padding-left: 3px;
- padding-right: 3px;
- border: 1px dotted #fff;
- border-radius: 4px;
+ pre code {
+ display: block;
+ padding: 8px;
}
blockquote {
diff --git a/apps/ssb/tf-utils.js b/apps/ssb/tf-utils.js
index 088d0b9b..e929d1ff 100644
--- a/apps/ssb/tf-utils.js
+++ b/apps/ssb/tf-utils.js
@@ -1,5 +1,7 @@
import * as hashtagify from './commonmark-hashtag.js';
+const k_code_classes = 'w3-theme-l4 w3-theme-border w3-round';
+
function image(node, entering) {
if (
node.firstChild?.type === 'text' &&
@@ -60,10 +62,20 @@ function image(node, entering) {
}
}
+function code(node) {
+ let attrs = this.attrs(node);
+ attrs.push(['class', k_code_classes]);
+ this.tag('code', attrs);
+ this.out(node.literal);
+ this.tag('/code');
+}
+
function attrs(node) {
let result = commonmark.HtmlRenderer.prototype.attrs.bind(this)(node);
if (node.type == 'block_quote') {
result.push(['class', 'w3-theme-d1']);
+ } else if (node.type == 'code_block') {
+ result.push(['class', k_code_classes]);
}
return result;
}
@@ -72,6 +84,7 @@ export function markdown(md) {
let reader = new commonmark.Parser({safe: true});
let writer = new commonmark.HtmlRenderer();
writer.image = image;
+ writer.code = code;
writer.attrs = attrs;
let parsed = reader.parse(md || '');
parsed = hashtagify.transform(parsed);