mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
support task lists in markdown-it
This commit is contained in:
parent
7a51ee5b3d
commit
bacd112782
@ -314,6 +314,7 @@ If you prefer command line on macOS, you could follow these steps.
|
||||
- [Ionicons 2.0.1](https://github.com/driftyco/ionicons/) (MIT License)
|
||||
- [markdown-it 8.3.1](https://github.com/markdown-it/markdown-it) (MIT License)
|
||||
- [markdown-it-headinganchor 1.3.0](https://github.com/adam-p/markdown-it-headinganchor) (MIT License)
|
||||
- [markdown-it-task-lists 1.4.0](https://github.com/revin/markdown-it-task-lists) (ISC License)
|
||||
|
||||
# License (代码许可)
|
||||
VNote is licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||
|
@ -65,6 +65,8 @@ mdit = mdit.use(window.markdownitHeadingAnchor, {
|
||||
}
|
||||
});
|
||||
|
||||
mdit = mdit.use(window.markdownitTaskLists);
|
||||
|
||||
var mdHasTocSection = function(markdown) {
|
||||
var n = markdown.search(/(\n|^)\[toc\]/i);
|
||||
return n != -1;
|
||||
|
@ -7,3 +7,7 @@ Vitaly Puzrin
|
||||
v1.3.0
|
||||
Adam Pritchard
|
||||
Modified by Le Tan
|
||||
|
||||
# [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists)
|
||||
v1.4.0
|
||||
Revin Guillen
|
||||
|
2
src/utils/markdown-it/markdown-it-task-lists.min.js
vendored
Normal file
2
src/utils/markdown-it/markdown-it-task-lists.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! markdown-it-task-lists 1.4.0 https://github.com/revin/markdown-it-task-lists#readme by @license {ISC} */
|
||||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.markdownitTaskLists=n()}}(function(){return function n(e,t,i){function r(c,f){if(!t[c]){if(!e[c]){var u="function"==typeof require&&require;if(!f&&u)return u(c,!0);if(o)return o(c,!0);var l=new Error("Cannot find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}var s=t[c]={exports:{}};e[c][0].call(s.exports,function(n){var t=e[c][1][n];return r(t?t:n)},s,s.exports,n,e,t,i)}return t[c].exports}for(var o="function"==typeof require&&require,c=0;c<i.length;c++)r(i[c]);return r}({1:[function(n,e,t){function i(n,e,t){var i=n.attrIndex(e),r=[e,t];0>i?n.attrPush(r):n.attrs[i]=r}function r(n,e){for(var t=n[e].level-1,i=e-1;i>=0;i--)if(n[i].level===t)return i;return-1}function o(n,e){return s(n[e])&&a(n[e-1])&&d(n[e-2])&&p(n[e])}function c(n,e){n.children.unshift(f(n,e)),n.children[1].content=n.children[1].content.slice(3),n.content=n.content.slice(3),x&&(n.children.unshift(u(e)),n.children.push(l(e)))}function f(n,e){var t=new e("html_inline","",0),i=h?' disabled="" ':"";return 0===n.content.indexOf("[ ]")?t.content='<input class="task-list-item-checkbox"'+i+'type="checkbox">':(0===n.content.indexOf("[x]")||0===n.content.indexOf("[X]"))&&(t.content='<input class="task-list-item-checkbox" checked=""'+i+'type="checkbox">'),t}function u(n){var e=new n("html_inline","",0);return e.content="<label>",e}function l(n){var e=new n("html_inline","",0);return e.content="</label>",e}function s(n){return"inline"===n.type}function a(n){return"paragraph_open"===n.type}function d(n){return"list_item_open"===n.type}function p(n){return 0===n.content.indexOf("[ ]")||0===n.content.indexOf("[x]")||0===n.content.indexOf("[X]")}var h=!0,x=!1;e.exports=function(n,e){e&&(h=!e.enabled,x=!!e.label),n.core.ruler.after("inline","github-task-lists",function(n){for(var e=n.tokens,t=2;t<e.length;t++)o(e,t)&&(c(e[t],n.Token),i(e[t-2],"class","task-list-item"),i(e[r(e,t-2)],"class","task-list"))})}},{}]},{},[1])(1)});
|
@ -290,7 +290,8 @@ void VEditTab::setupMarkdownPreview()
|
||||
case MarkdownConverterType::MarkdownIt:
|
||||
jsFile = "qrc" + VNote::c_markdownitJsFile;
|
||||
extraFile = "<script src=\"qrc" + VNote::c_markdownitExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitTocExtraFile + "\"></script>";
|
||||
"<script src=\"qrc" + VNote::c_markdownitAnchorExtraFile + "\"></script>\n" +
|
||||
"<script src=\"qrc" + VNote::c_markdownitTaskListExtraFile + "\"></script>";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -16,7 +16,8 @@ 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_markdownitTocExtraFile = ":/utils/markdown-it/markdown-it-headinganchor.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";
|
||||
|
||||
VNote::VNote(QObject *parent)
|
||||
: QObject(parent), m_mainWindow(dynamic_cast<VMainWindow *>(parent))
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
// Markdown-it
|
||||
static const QString c_markdownitJsFile;
|
||||
static const QString c_markdownitExtraFile;
|
||||
static const QString c_markdownitTocExtraFile;
|
||||
static const QString c_markdownitAnchorExtraFile;
|
||||
static const QString c_markdownitTaskListExtraFile;
|
||||
|
||||
inline const QVector<QPair<QString, QString> > &getPalette() const;
|
||||
void initPalette(QPalette palette);
|
||||
|
@ -89,5 +89,6 @@
|
||||
<file>resources/markdown-it.js</file>
|
||||
<file>utils/markdown-it/markdown-it.min.js</file>
|
||||
<file>utils/markdown-it/markdown-it-headinganchor.js</file>
|
||||
<file>utils/markdown-it/markdown-it-task-lists.min.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user