From c2513fd931be0be75f0bed640fead204fdf1e21c Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sun, 10 Dec 2017 22:59:18 +0200 Subject: [PATCH 1/4] 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 @@ + + + From f898ad3d56cd7b483af67866848886fce5d6cfbf Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sun, 10 Dec 2017 23:02:23 +0200 Subject: [PATCH 2/4] Add more markdown examples to help Because we now have extra non-GFM features (ins, mark) --- nyaa/templates/help.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nyaa/templates/help.html b/nyaa/templates/help.html index 16ccfdb..50a61a0 100644 --- a/nyaa/templates/help.html +++ b/nyaa/templates/help.html @@ -81,6 +81,23 @@ to have an image embedded in your comment or description. Note the ! exclamation mark at the beginning, denoting that this link is an image. +
+ Quick examples: +
+
+
    +
  • *italic text*italic text
  • +
  • **bold text**bold text
  • +
  • ++underlined text++underlined text
  • +
  • ==marked text==marked text
  • +
  • [Front page]({{url_for('main.home')}})Front page
  • +
  • [Spoilers](# "The spider-girl kills everyone")Spoilers
  • +
  • # Header 1

    Header 1

  • +
  • ## Header 2

    Header 2

  • +
  • ### Header 3

    Header 3

  • +
  • #### Header 4

    Header 4

  • +
+
{{ linkable_header("Changing Your User's Avatar", "avatar") }}
From 9106977fadfe2db34109e004970399ecb59bb486 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Sun, 10 Dec 2017 23:08:44 +0200 Subject: [PATCH 3/4] Change "Markdown supported" to link to our own help ...because and . --- nyaa/templates/_formhelpers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/_formhelpers.html b/nyaa/templates/_formhelpers.html index a73d366..1fab1e1 100644 --- a/nyaa/templates/_formhelpers.html +++ b/nyaa/templates/_formhelpers.html @@ -35,7 +35,7 @@ {% endif %}
{{ field.label(class='control-label') }} - Markdown supported + Markdown supported