qownnotes-mermaid-dark.qml: Fork of QOwnNotes' Mermaid script for dark theme
This commit is contained in:
parent
4f3f8056b3
commit
cb42356bcd
2 changed files with 30 additions and 0 deletions
|
@ -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
|
||||
|
|
29
qownnotes-mermaid-dark.qml
Normal file
29
qownnotes-mermaid-dark.qml
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue