qownnotes-mermaid-dark.qml: Fork of QOwnNotes' Mermaid script for dark theme

This commit is contained in:
n 2023-07-15 22:52:00 +02:00
parent 4f3f8056b3
commit cb42356bcd
Signed by: n
GPG key ID: 510227DD6C502CE3
2 changed files with 30 additions and 0 deletions

View file

@ -13,6 +13,7 @@ Scripts
* [dump_mysql.sh](https://forge.tourmentine.com/n/scripts/src/main/dump_mysql.sh) => dump all mysql databases (and send a report to the monitoring system)
* [dump_postgresql.sh](https://forge.tourmentine.com/n/scripts/src/main/dump_postgresql.sh) => dump all Postgres databases (and send a report to the monitoring system). based on [dump_mysql.sh](https://forge.tourmentine.com/n/scripts/src/main/dump_mysql.sh).
* [opdsupdates.py](https://forge.tourmentine.com/n/scripts/src/main/opdsupdates.py) => look for OPDS catalog updates and send a mail if any
* [qownnotes-mermaid-dark.qml](https://forge.tourmentine.com/n/scripts/src/main/qownnotes-mermaid-dark.qml) => Fork of QOwnNotes' [Mermaid script](https://github.com/qownnotes/scripts/tree/master/mermaid) for dark theme
* [randomwallpaper.sh](https://forge.tourmentine.com/n/scripts/src/main/randomwallpaper.sh) => display a random wallpaper
* [secupdate](https://forge.tourmentine.com/n/scripts/src/main/secupdate) => apply security updates & recompile kernel (FreeBSD)
* [superscreen](https://forge.tourmentine.com/n/scripts/src/main/superscreen) => open multiple ssh sessions to a bunch of servers inside a screen

View file

@ -0,0 +1,29 @@
import QtQml 2.0
import QOwnNotesTypes 1.0
QtObject {
/**
* This function is called before the markdown html of a note is generated
*
* It allows you to modify what is passed to the markdown to html converter
*
* The method can for example be used in multiple scripts to render code (like LaTeX math or mermaid)
* to its graphical representation for the preview
*
* The note will not be changed in this process
*
* @param {NoteApi} note - the note object
* @param {string} markdown - the markdown that is about to being converted to html
* @param {string} forExport - true if the html is used for an export, false for the preview
* @return {string} the modified markdown or an empty string if nothing should be modified
*/
function preNoteToMarkdownHtmlHook(note, markdown, forExport) {
var re = /```mermaid\n([\s\S]*?)\n```/gim;
markdown = markdown.replace(re, function(_, diag){
var encodedData = Qt.btoa(diag);
var ink = '![](https://mermaid.ink/img/' + encodedData + '?bgColor=!201F1F)';
return ink;
});
return markdown;
}
}