From 99f8fd4e08b4b8c33dcc0151aff387256dfa3618 Mon Sep 17 00:00:00 2001 From: m-wim Date: Sun, 10 Dec 2017 19:11:18 +0100 Subject: [PATCH] Added new script to replace square brackets on list items with single checkbox symbols. --- export-checkboxes/export-checkboxes.qml | 24 ++++++++++++++++++++++++ export-checkboxes/info.json | 9 +++++++++ 2 files changed, 33 insertions(+) create mode 100644 export-checkboxes/export-checkboxes.qml create mode 100644 export-checkboxes/info.json diff --git a/export-checkboxes/export-checkboxes.qml b/export-checkboxes/export-checkboxes.qml new file mode 100644 index 0000000..ca7879d --- /dev/null +++ b/export-checkboxes/export-checkboxes.qml @@ -0,0 +1,24 @@ +import QtQml 2.0 + +/** + * This is an example for custom styling of html in the note preview + */ +QtObject { + /** + * This function is called when the markdown html of a note is generated + * + * It allows you to modify this html + * This is for example called before by the note preview + * + * @param {Note} note - the note object + * @param {string} html - the html that is about to being rendered + * @return {string} the modfied html or an empty string if nothing should be modified + */ + function noteToMarkdownHtmlHook(note, html) { + // see http://doc.qt.io/qt-5/richtext-html-subset.html for a list of + // supported css styles + html = html.replace(/
  • (\s*)(

    )*(\s*)\[x\]/g, "

  • $1$2$3☑"); + html = html.replace(/
  • (\s*)(

    )*(\s*)\[ \]/g, "

  • $1$2$3☐"); + return html; + } +} \ No newline at end of file diff --git a/export-checkboxes/info.json b/export-checkboxes/info.json new file mode 100644 index 0000000..7f1ae9e --- /dev/null +++ b/export-checkboxes/info.json @@ -0,0 +1,9 @@ +{ + "name": "Export checkboxes", + "identifier": "export-checkboxes", + "script": "export-checkboxes.qml", + "version": "0.0.1", + "minAppVersion": "17.12.0", + "authors": ["@m-wim"], + "description" : "This script changes the html output. If list items start with a check box mark the list bullet and mark is replaced with a single UTF-8 character for checked/unchecked state." +}