summaryrefslogtreecommitdiff
path: root/public/js/extra.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--public/js/extra.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index d6bbb0c6..ed1470be 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -570,7 +570,9 @@ export function postProcess (code) {
$(value).html(html)
})
// link should open in new window or tab
- result.find('a:not([href^="#"]):not([target])').attr('target', '_blank')
+ // also add noopener to prevent clickjacking
+ // See details: https://mathiasbynens.github.io/rel-noopener/
+ result.find('a:not([href^="#"]):not([target])').attr('target', '_blank').attr('rel', 'noopener')
// update continue line numbers
const linenumberdivs = result.find('.gutter.linenumber').toArray()
for (let i = 0; i < linenumberdivs.length; i++) {
@@ -832,7 +834,7 @@ const anchorForId = id => {
const anchor = document.createElement('a')
anchor.className = 'anchor hidden-xs'
anchor.href = `#${id}`
- anchor.innerHTML = '<span class="octicon octicon-link"></span>'
+ anchor.innerHTML = '<i class="fa fa-link"></i>'
anchor.title = id
return anchor
}
@@ -1143,6 +1145,19 @@ const pdfPlugin = new Plugin(
}
)
+const emojijsPlugin = new Plugin(
+ // regexp to match emoji shortcodes :something:
+ // We generate an universal regex that guaranteed only contains the
+ // emojies we have available. This should prevent all false-positives
+ new RegExp(':(' + window.emojify.emojiNames.map((item) => { return RegExp.escape(item) }).join('|') + '):', 'i'),
+
+ (match, utils) => {
+ const emoji = match[1].toLowerCase()
+ const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`)
+ return div[0].outerHTML
+ }
+)
+
// yaml meta, from https://github.com/eugeneware/remarkable-meta
function get (state, line) {
const pos = state.bMarks[line]
@@ -1187,6 +1202,7 @@ function metaPlugin (md) {
}
md.use(metaPlugin)
+md.use(emojijsPlugin)
md.use(youtubePlugin)
md.use(vimeoPlugin)
md.use(gistPlugin)