aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-26 14:09:37 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-12-26 14:09:37 -1000
commit0c6c333f1c7b9c3ab062d26a4b2541de055307f6 (patch)
tree48517c81acd3341741539968aae4c8cc7cf4b592 /lib
parente6c57e42071b9b49737c820a3cdfd14cd4864ce3 (diff)
downloadpatchfoo-0c6c333f1c7b9c3ab062d26a4b2541de055307f6.tar.gz
patchfoo-0c6c333f1c7b9c3ab062d26a4b2541de055307f6.zip
Use textarea for code blocks
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js12
-rw-r--r--lib/serve.js6
-rw-r--r--lib/util.js4
3 files changed, 17 insertions, 5 deletions
diff --git a/lib/render.js b/lib/render.js
index 95c8c50..ace346d 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -62,6 +62,18 @@ MdRenderer.prototype.mention = function (preceding, id) {
}, id).outerHTML
}
+MdRenderer.prototype.code = function (code, lang, escaped) {
+ if (void 'TODO: check a config option') {
+ 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) {
var el = this.renderer.render.emoji(emoji)
return el && el.outerHTML || el
diff --git a/lib/serve.js b/lib/serve.js
index 76b3a8c..766b524 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -2433,10 +2433,6 @@ Serve.prototype.wrapMyChannels = function (opts) {
})
}
-function rows(str) {
- return String(str).split(/[^\n]{150}|\n/).length
-}
-
Serve.prototype.composer = function (opts, cb) {
var self = this
opts = opts || {}
@@ -2551,7 +2547,7 @@ Serve.prototype.composer = function (opts, cb) {
h('textarea', {
id: opts.id,
name: 'text',
- rows: Math.max(4, rows(data.text)),
+ rows: Math.max(4, u.rows(data.text)),
cols: 70,
placeholder: opts.placeholder || 'public message',
}, data.text || ''),
diff --git a/lib/util.js b/lib/util.js
index 7425513..15eb295 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -218,3 +218,7 @@ u.unescapeId = function (str) {
if (!m) return b64url.unescape(str)
return m[1] + b64url.unescape(m[2]) + m[3]
}
+
+u.rows = function (str) {
+ return String(str).split(/[^\n]{150}|\n/).length
+}