1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-12-21 23:48:08 +00:00

Rewrite to address issue #925 (#43)

* Added myself to authors and incremented version number

* Rewrite that uses the mark element

* per request changed spelling of color, changed setting name,  and re-added custom action
This commit is contained in:
ryliejamesthomas 2018-10-30 16:19:18 +11:00 committed by Patrizio Bekerle
parent 63edc8588a
commit 7f27b4d9a7
2 changed files with 11 additions and 11 deletions

View file

@ -2,9 +2,9 @@
"name": "Text Highlights", "name": "Text Highlights",
"identifier": "text-highlights", "identifier": "text-highlights",
"script": "text-highlights.qml", "script": "text-highlights.qml",
"authors": ["@mleo2003"], "authors": ["@mleo2003", "@ryliejamesthomas"],
"platforms": ["linux", "macos", "windows"], "platforms": ["linux", "macos", "windows"],
"version": "0.0.2", "version": "0.0.3",
"minAppVersion": "17.06.2", "minAppVersion": "17.06.2",
"description" : "Provide a way to highlight text in markdown and render it as some other markdown viewers do. Uses ==text== syntax, and the color shown is configurable." "description" : "Provide a way to highlight text in markdown and render it as some other markdown viewers do. Uses ==text== syntax, and the color shown is configurable."
} }

View file

@ -2,29 +2,29 @@ import QtQml 2.0
import QOwnNotesTypes 1.0 import QOwnNotesTypes 1.0
QtObject { QtObject {
property string highlightColor; property string backgroundColor;
property variant settingsVariables: [ property variant settingsVariables: [
{ {
"identifier": "highlightColor", "identifier": "backgroundColor",
"name": "Highlight Color", "name": "Highlight Color",
"description": "Color to highlight text as", "description": "Color to highlight text with (name or #hex):",
"type": "string", "type": "string",
"default": "FFFF00", "default": "#FFFF00",
} }
]; ];
function noteToMarkdownHtmlHook(note, html) { function noteToMarkdownHtmlHook(note, html) {
var stylesheet = ".highlighted {background-color: #" + highlightColor + ";}"; var stylesheet = "mark {background-color:" + backgroundColor + ";}";
html = html.replace(/==(.+?)==/g, "<span class='highlighted'>$1</span>"); html = html.replace(/==(.+?)==/g, "<mark>$1</mark>");
html = html.replace("</style>", stylesheet + "</style>"); html = html.replace("</style>", stylesheet + "</style>");
return html; return html;
} }
function init() { function init() {
script.registerCustomAction("addHighlights", "Add Highlight Marks", "Add Highlights", "text-wrap"); script.registerCustomAction("addHighlights", "Add Highlight Marks", "Add Highlights", "text-wrap");
} }
function customActionInvoked(identifier) { function customActionInvoked(identifier) {
switch (identifier) { switch (identifier) {
case "addHighlights": case "addHighlights":