From c2513fd931be0be75f0bed640fead204fdf1e21c Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sun, 10 Dec 2017 22:59:18 +0200 Subject: [PATCH] Add underline and hilight support to Markdown renderer ++underline++ and ==hilight==, also known as and The markdown-it-ins and markdown-it-mark are not available on CF's cdnjs, so selfhost them. (They are on jsdeliver, but it's better to rely on our own host than add another 3rd party.) Improves visibility (color) of a bit as well. --- nyaa/static/css/main.css | 8 +++++++- nyaa/static/js/lib/markdown-it-ins.min.js | 2 ++ nyaa/static/js/lib/markdown-it-mark.min.js | 2 ++ nyaa/static/js/main.js | 2 +- nyaa/templates/layout.html | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 nyaa/static/js/lib/markdown-it-ins.min.js create mode 100644 nyaa/static/js/lib/markdown-it-mark.min.js diff --git a/nyaa/static/css/main.css b/nyaa/static/css/main.css index 525e0a1..1209500 100644 --- a/nyaa/static/css/main.css +++ b/nyaa/static/css/main.css @@ -570,4 +570,10 @@ td.report-action-column { /* Override
font size (assume main.css comes after bootstrap) */ blockquote { font-size: inherit; -} \ No newline at end of file +} + +/* Make s a bit more prominent */ +mark, .mark { + background-color: #fff6c9; + padding: .2em; +} diff --git a/nyaa/static/js/lib/markdown-it-ins.min.js b/nyaa/static/js/lib/markdown-it-ins.min.js new file mode 100644 index 0000000..11aaa3f --- /dev/null +++ b/nyaa/static/js/lib/markdown-it-ins.min.js @@ -0,0 +1,2 @@ +/*! markdown-it-ins 2.0.0 https://github.com//markdown-it/markdown-it-ins @license MIT */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.markdownitIns=e()}}(function(){return function e(n,t,o){function r(s,f){if(!t[s]){if(!n[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=t[s]={exports:{}};n[s][0].call(p.exports,function(e){var t=n[s][1][e];return r(t?t:e)},p,p.exports,e,n,t,o)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;si)return!1;for(i%2&&(r=e.push("text","",0),r.content=s,i--),t=0;i>t;t+=2)r=e.push("text","",0),r.content=s+s,e.delimiters.push({marker:u,jump:t,token:e.tokens.length-1,level:e.level,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0}function t(e){var n,t,o,r,i,s=[],f=e.delimiters,u=e.delimiters.length;for(n=0;u>n;n++)o=f[n],43===o.marker&&-1!==o.end&&(r=f[o.end],i=e.tokens[o.token],i.type="ins_open",i.tag="ins",i.nesting=1,i.markup="++",i.content="",i=e.tokens[r.token],i.type="ins_close",i.tag="ins",i.nesting=-1,i.markup="++",i.content="","text"===e.tokens[r.token-1].type&&"+"===e.tokens[r.token-1].content&&s.push(r.token-1));for(;s.length;){for(n=s.pop(),t=n+1;ti)return!1;for(i%2&&(r=e.push("text","",0),r.content=s,i--),t=0;i>t;t+=2)r=e.push("text","",0),r.content=s+s,e.delimiters.push({marker:u,jump:t,token:e.tokens.length-1,level:e.level,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0}function t(e){var n,t,o,r,i,s=[],f=e.delimiters,u=e.delimiters.length;for(n=0;u>n;n++)o=f[n],61===o.marker&&-1!==o.end&&(r=f[o.end],i=e.tokens[o.token],i.type="mark_open",i.tag="mark",i.nesting=1,i.markup="==",i.content="",i=e.tokens[r.token],i.type="mark_close",i.tag="mark",i.nesting=-1,i.markup="==",i.content="","text"===e.tokens[r.token-1].type&&"="===e.tokens[r.token-1].content&&s.push(r.token-1));for(;s.length;){for(n=s.pop(),t=n+1;t'; diff --git a/nyaa/templates/layout.html b/nyaa/templates/layout.html index a37009e..79c7b42 100644 --- a/nyaa/templates/layout.html +++ b/nyaa/templates/layout.html @@ -44,6 +44,9 @@ + + +