mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-21 23:48:08 +00:00
added script paste-html-as-github-markdown
This commit is contained in:
parent
996974bb46
commit
c3c5a1d5d2
2 changed files with 57 additions and 0 deletions
9
paste-html-as-github-markdown/info.json
Normal file
9
paste-html-as-github-markdown/info.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "Paste HTML as GitHub Markdown",
|
||||||
|
"identifier": "paste-html-as-github-markdown",
|
||||||
|
"script": "paste-html-as-github-markdown.qml",
|
||||||
|
"authors": ["@pbek"],
|
||||||
|
"version": "0.0.1",
|
||||||
|
"minAppVersion": "17.08.2",
|
||||||
|
"description" : "With this script you can right click in the note edit and paste previously copied HTML from a website as GitHub Markdown with the help of Pandoc.\n\n<b>Dependencies</b>\n<a href=\"http://pandoc.org\">Pandoc</a>\n\n<b>Installation</b>\nAfter you have installed <i>Pandoc</i> you have to configure its path in the script settings."
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
import QtQml 2.0
|
||||||
|
import QOwnNotesTypes 1.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With this script you can right click in the note edit and paste previously copied HTML
|
||||||
|
* from a website as GitHub Markdown with the help of Pandoc.
|
||||||
|
*/
|
||||||
|
Script {
|
||||||
|
property string pandocPath;
|
||||||
|
|
||||||
|
// register your settings variables so the user can set them in the script settings
|
||||||
|
property variant settingsVariables: [
|
||||||
|
{
|
||||||
|
"identifier": "pandocPath",
|
||||||
|
"name": "Pandoc path",
|
||||||
|
"description": "Please select the path to your Pandoc executable:",
|
||||||
|
"type": "file",
|
||||||
|
"default": "pandoc",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the custom action
|
||||||
|
*/
|
||||||
|
function init() {
|
||||||
|
script.registerCustomAction("html2Markdown", "Paste HTML as GitHub Markdown", "GitHub Markdown", "edit-paste", true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is invoked when a custom action is triggered
|
||||||
|
* in the menu or via button
|
||||||
|
*
|
||||||
|
* @param identifier string the identifier defined in registerCustomAction
|
||||||
|
*/
|
||||||
|
function customActionInvoked(identifier) {
|
||||||
|
if (identifier != "html2Markdown") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = script.clipboard(true);
|
||||||
|
|
||||||
|
// you need pandoc to convert HTML to Markdown
|
||||||
|
var params = ["-f", "html", "-t", "markdown_github"];
|
||||||
|
var markdown = script.startSynchronousProcess(pandocPath, params, html);
|
||||||
|
|
||||||
|
script.noteTextEditWrite(markdown);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue