diff --git a/src/resources/markdown-it.js b/src/resources/markdown-it.js index cee6ac5b..e7303eb1 100644 --- a/src/resources/markdown-it.js +++ b/src/resources/markdown-it.js @@ -66,6 +66,9 @@ mdit = mdit.use(window.markdownitHeadingAnchor, { }); mdit = mdit.use(window.markdownitTaskLists); +mdit = mdit.use(window.markdownitSub); +mdit = mdit.use(window.markdownitSup); +mdit = mdit.use(window.markdownitFootnote); var mdHasTocSection = function(markdown) { var n = markdown.search(/(\n|^)\[toc\]/i); diff --git a/src/utils/markdown-it/markdown-it-footnote.min.js b/src/utils/markdown-it/markdown-it-footnote.min.js new file mode 100644 index 00000000..d0271179 --- /dev/null +++ b/src/utils/markdown-it/markdown-it-footnote.min.js @@ -0,0 +1,2 @@ +/*! markdown-it-footnote 3.0.1 https://github.com//markdown-it/markdown-it-footnote @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 o;o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,o.markdownitFootnote=e()}}(function(){return function e(o,t,n){function r(f,l){if(!t[f]){if(!o[f]){var u="function"==typeof require&&require;if(!l&&u)return u(f,!0);if(s)return s(f,!0);var i=new Error("Cannot find module '"+f+"'");throw i.code="MODULE_NOT_FOUND",i}var a=t[f]={exports:{}};o[f][0].call(a.exports,function(e){var t=o[f][1][e];return r(t?t:e)},a,a.exports,e,o,t,n)}return t[f].exports}for(var s="function"==typeof require&&require,f=0;f0&&(t+=":"+e[o].meta.subId),"["+t+"]"}function s(e,o,t,n,r){var s=r.rules.footnote_anchor_name(e,o,t,n,r),f=r.rules.footnote_caption(e,o,t,n,r),l=s;return e[o].meta.subId>0&&(l+=":"+e[o].meta.subId),''+f+""}function f(e,o,t){return(t.xhtmlOut?'
\n':'
\n')+'
\n
    \n'}function l(){return"
\n
\n"}function u(e,o,t,n,r){var s=r.rules.footnote_anchor_name(e,o,t,n,r);return e[o].meta.subId>0&&(s+=":"+e[o].meta.subId),'
  • '}function i(){return"
  • \n"}function a(e,o,t,n,r){var s=r.rules.footnote_anchor_name(e,o,t,n,r);return e[o].meta.subId>0&&(s+=":"+e[o].meta.subId),' \u21a9\ufe0e'}o.exports=function(e){function o(e,o,t,n){var r,s,f,l,u,i,a,c,p,d,k,b=e.bMarks[o]+e.tShift[o],v=e.eMarks[o];if(b+4>v)return!1;if(91!==e.src.charCodeAt(b))return!1;if(94!==e.src.charCodeAt(b+1))return!1;for(u=b+2;u=v||58!==e.src.charCodeAt(++u))return!1;if(n)return!0;for(u++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),i=e.src.slice(b+2,u-2),e.env.footnotes.refs[":"+i]=-1,a=new e.Token("footnote_reference_open","",1),a.meta={label:i},a.level=e.level++,e.tokens.push(a),r=e.bMarks[o],s=e.tShift[o],f=e.sCount[o],l=e.parentType,k=u,c=p=e.sCount[o]+u-(e.bMarks[o]+e.tShift[o]);u=l)&&(94===e.src.charCodeAt(u)&&(91===e.src.charCodeAt(u+1)&&(t=u+2,n=d(e,u+1),!(n<0)&&(o||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),r=e.env.footnotes.list.length,e.md.inline.parse(e.src.slice(t,n),e.md,e.env,f=[]),s=e.push("footnote_ref","",0),s.meta={id:r},e.env.footnotes.list[r]={tokens:f}),e.pos=n+1,e.posMax=l,!0))))}function c(e,o){var t,n,r,s,f,l=e.posMax,u=e.pos;if(u+3>l)return!1;if(!e.env.footnotes||!e.env.footnotes.refs)return!1;if(91!==e.src.charCodeAt(u))return!1;if(94!==e.src.charCodeAt(u+1))return!1;for(n=u+2;n=l)&&(n++,t=e.src.slice(u+2,n-1),"undefined"!=typeof e.env.footnotes.refs[":"+t]&&(o||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+t]<0?(r=e.env.footnotes.list.length,e.env.footnotes.list[r]={label:t,count:0},e.env.footnotes.refs[":"+t]=r):r=e.env.footnotes.refs[":"+t],s=e.env.footnotes.list[r].count,e.env.footnotes.list[r].count++,f=e.push("footnote_ref","",0),f.meta={id:r,subId:s,label:t}),e.pos=n,e.posMax=l,!0)))}function p(e){var o,t,n,r,s,f,l,u,i,a,c=!1,p={};if(e.env.footnotes&&(e.tokens=e.tokens.filter(function(e){return"footnote_reference_open"===e.type?(c=!0,i=[],a=e.meta.label,!1):"footnote_reference_close"===e.type?(c=!1,p[":"+a]=i,!1):(c&&i.push(e),!c)}),e.env.footnotes.list)){for(f=e.env.footnotes.list,l=new e.Token("footnote_block_open","",1),e.tokens.push(l),o=0,t=f.length;o0?f[o].count:1,n=0;n=i)return!1;for(e.pos=u+1;e.pos?@[\]^_`{|}~-])/g;r.exports=function(e){e.inline.ruler.after("emphasis","sub",o)}},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/src/utils/markdown-it/markdown-it-sup.min.js b/src/utils/markdown-it/markdown-it-sup.min.js new file mode 100644 index 00000000..67da65cd --- /dev/null +++ b/src/utils/markdown-it/markdown-it-sup.min.js @@ -0,0 +1,2 @@ +/*! markdown-it-sup 1.0.0 https://github.com//markdown-it/markdown-it-sup @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 r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.markdownitSup=e()}}(function(){return function e(r,o,n){function t(i,p){if(!o[i]){if(!r[i]){var u="function"==typeof require&&require;if(!p&&u)return u(i,!0);if(s)return s(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var a=o[i]={exports:{}};r[i][0].call(a.exports,function(e){var o=r[i][1][e];return t(o?o:e)},a,a.exports,e,r,o,n)}return o[i].exports}for(var s="function"==typeof require&&require,i=0;i=i)return!1;for(e.pos=p+1;e.pos?@[\]^_`{|}~-])/g;r.exports=function(e){e.inline.ruler.after("emphasis","sup",o)}},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp index d6aec63b..93f10230 100644 --- a/src/vmdtab.cpp +++ b/src/vmdtab.cpp @@ -300,7 +300,10 @@ QString VMdTab::fillHtmlTemplate() const jsFile = "qrc" + VNote::c_markdownitJsFile; extraFile = "\n" + "\n" + - "\n"; + "\n" + + "\n" + + "\n" + + "\n"; break; case MarkdownConverterType::Showdown: diff --git a/src/vnote.cpp b/src/vnote.cpp index f4db89e0..4f115e15 100644 --- a/src/vnote.cpp +++ b/src/vnote.cpp @@ -19,12 +19,18 @@ QString VNote::s_markdownTemplate; QString VNote::s_markdownTemplatePDF; const QString VNote::c_hoedownJsFile = ":/resources/hoedown.js"; + const QString VNote::c_markedJsFile = ":/resources/marked.js"; const QString VNote::c_markedExtraFile = ":/utils/marked/marked.min.js"; + const QString VNote::c_markdownitJsFile = ":/resources/markdown-it.js"; const QString VNote::c_markdownitExtraFile = ":/utils/markdown-it/markdown-it.min.js"; const QString VNote::c_markdownitAnchorExtraFile = ":/utils/markdown-it/markdown-it-headinganchor.js"; const QString VNote::c_markdownitTaskListExtraFile = ":/utils/markdown-it/markdown-it-task-lists.min.js"; +const QString VNote::c_markdownitSubExtraFile = ":/utils/markdown-it/markdown-it-sub.min.js"; +const QString VNote::c_markdownitSupExtraFile = ":/utils/markdown-it/markdown-it-sup.min.js"; +const QString VNote::c_markdownitFootnoteExtraFile = ":/utils/markdown-it/markdown-it-footnote.min.js"; + const QString VNote::c_showdownJsFile = ":/resources/showdown.js"; const QString VNote::c_showdownExtraFile = ":/utils/showdown/showdown.min.js"; const QString VNote::c_showdownAnchorExtraFile = ":/utils/showdown/showdown-headinganchor.js"; @@ -33,7 +39,9 @@ const QString VNote::c_mermaidApiJsFile = ":/utils/mermaid/mermaidAPI.min.js"; const QString VNote::c_mermaidCssFile = ":/utils/mermaid/mermaid.css"; const QString VNote::c_mermaidDarkCssFile = ":/utils/mermaid/mermaid.dark.css"; const QString VNote::c_mermaidForestCssFile = ":/utils/mermaid/mermaid.forest.css"; + const QString VNote::c_mathjaxJsFile = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"; + const QString VNote::c_shortcutsDocFile_en = ":/resources/docs/shortcuts_en.md"; const QString VNote::c_shortcutsDocFile_zh = ":/resources/docs/shortcuts_zh.md"; diff --git a/src/vnote.h b/src/vnote.h index 4239ad3d..e8055def 100644 --- a/src/vnote.h +++ b/src/vnote.h @@ -42,6 +42,9 @@ public: static const QString c_markdownitExtraFile; static const QString c_markdownitAnchorExtraFile; static const QString c_markdownitTaskListExtraFile; + static const QString c_markdownitSubExtraFile; + static const QString c_markdownitSupExtraFile; + static const QString c_markdownitFootnoteExtraFile; // Showdown static const QString c_showdownJsFile; diff --git a/src/vnote.qrc b/src/vnote.qrc index 4fd24960..10147262 100644 --- a/src/vnote.qrc +++ b/src/vnote.qrc @@ -105,5 +105,8 @@ resources/showdown.js utils/showdown/showdown-headinganchor.js resources/icons/print.svg + utils/markdown-it/markdown-it-sub.min.js + utils/markdown-it/markdown-it-sup.min.js + utils/markdown-it/markdown-it-footnote.min.js