-
Notifications
You must be signed in to change notification settings - Fork 0
/
Markdown File.js
36 lines (31 loc) · 1.06 KB
/
Markdown File.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-brown; icon-glyph: file-alt;
// share-sheet-inputs: file-url;
// @ts-ignore
// eslint-disable-next-line
try { require; } catch(e) { require = importModule; }
const {
string, getInput, readText, external, showHtml
} = require('./lib/lib.js');
const main = async () => {
const input = await getInput({
name: 'Markdown File',
help: 'Converts a markdown file (or string) to HTML and displays it.',
inScriptable: true,
args: [{
name: 'file',
shortName: 'f',
type: 'pathFile',
bookmarkName: 'markdown-file',
share: true,
help: 'The markdown files to convert.'
}]
});
if (!input) { return; }
const file = string(input.file);
const content = file.indexOf('\n') > -1 ? file : await readText(file);
const markdown = content || 'Error: File Not Found';
showHtml(external.markedTemplates.html(external.marked(markdown)));
};
main();