diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-27 14:18:30 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-01-10 21:28:44 -1000 |
commit | 23cd085f4cf52dfdd2d00b75c2370cf34508a98a (patch) | |
tree | d7fb1dbf9b34623312f49a2f10f8963a49086e2b | |
parent | 0c6c333f1c7b9c3ab062d26a4b2541de055307f6 (diff) | |
download | patchfoo-23cd085f4cf52dfdd2d00b75c2370cf34508a98a.tar.gz patchfoo-23cd085f4cf52dfdd2d00b75c2370cf34508a98a.zip |
Add codeInTextareas option
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lib/app.js | 1 | ||||
-rw-r--r-- | lib/render.js | 14 |
3 files changed, 9 insertions, 7 deletions
@@ -93,6 +93,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: - `showPrivates`: Whether or not to show private messages. Default is `true`. Overridden by `filter=all`. - `previewVotes`: Whether to preview creating votes/likes/digs (`true`) or publish them immediately (`false`). default: `false` - `ooo`: if true, use `ssb-ooo` to try to fetch missing messages in threads. also can set per-request with query string `?ooo=1`. default: `false` +`codeInTextareas`: if `true`, render markdown code blocks in textareas. if `false`, render them in `pre` tags. default: `false` ## TODO @@ -41,6 +41,7 @@ function App(sbot, config) { img_base: conf.img_base || (base + 'image/'), emoji_base: conf.emoji_base || (base + 'emoji/'), encode_msgids: conf.encode_msgids == null ? true : Boolean(conf.encode_msgids), + codeInTextareas: conf.codeInTextareas, } sbot.get = memo({cache: lru(100)}, sbot.get) diff --git a/lib/render.js b/lib/render.js index ace346d..fd357a0 100644 --- a/lib/render.js +++ b/lib/render.js @@ -63,15 +63,15 @@ MdRenderer.prototype.mention = function (preceding, id) { } MdRenderer.prototype.code = function (code, lang, escaped) { - if (void 'TODO: check a config option') { + if (this.render.opts.codeInTextareas) { + return h('div', h('textarea', { + cols: 80, + rows: u.rows(code), + innerHTML: escaped ? code : u.escapeHTML(code) + })).outerHTML + } else { return marked.Renderer.prototype.code.call(this, code, lang, escaped) } - // render as a textarea for better line wrapping in dillo - return h('textarea', { - cols: 80, - rows: u.rows(code), - innerHTML: escaped ? code : u.escapeHTML(code) - }).outerHTML } function lexerRenderEmoji(emoji) { |