pandoc/trypandoc/index.html

225 lines
9.2 KiB
HTML
Raw Normal View History

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Try pandoc!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
body { margin: auto; font-family: sans-serif; font-size: 10pt; color: #555; }
#command { min-width: 26em; background-color: #555; color: #eee; border-radius: 9pt; margin: 6pt; padding: 6pt; }
h1 { margin-bottom: 1em; font-size: 166%; margin: 0; padding: 6pt; }
h1 a { text-decoration: none; color: inherit; }
label { font-weight: 600; }
textarea { height: auto; font-family: monospace; font-size: 10pt; margin-top: 15px; min-height: 65vh; width: 44vw; }
div.alert { margin: 1em; }
pre#results { width: 100%; margin-top: 15px; min-height: 65vh; width: 44vw; }
footer { color: #555; text-align: center; margin: 1em; }
p.version { color: #555; }
.container { margin: 12px; }
.row { display: flex; flex-wrap: nowrap; justify-content: space-between; }
#frompane { flex: 1; padding: 1em; }
#topane { flex: 1; padding: 1em; }
#command { font-family: monospace; padding: 1em; }
button#convert { vertical-align: bottom; }
2015-06-02 12:38:31 +02:00
pre#command { margin-top: 1em; background-color: transparent; border: none; }
</style>
</head>
<body>
<div class="container">
<div class="row">
<div id="title">
<h1>Try <a href="https://pandoc.org">pandoc</a>!</h1>
</div>
<div id="versioninfo">
<p class="version">v<span id="version"></span></p>
</footer>
</div>
<div id="command">
<pre id="command"></pre>
</div>
</div>
<div class="row">
<div id="frompane">
<button id="convert">Convert</button>
&nbsp;
<label for="from">
from
</label>
<select id="from">
2017-10-30 01:05:06 +01:00
<option value="commonmark">CommonMark</option>
<option value="creole">Creole</option>
2015-12-07 18:15:34 +01:00
<option value="docbook">DocBook</option>
<option value="dokuwiki">DokuWiki</option>
<option value="fb2">FB2</option>
2015-12-07 18:15:34 +01:00
<option value="haddock">Haddock markup</option>
<option value="html">HTML</option>
<option value="jats">JATS</option>
2019-12-23 07:11:41 +01:00
<option value="jira">Jira</option>
<option value="ipynb">Jupyter Notebook (ipynb)</option>
2015-12-07 18:15:34 +01:00
<option value="latex">LaTeX</option>
2018-11-04 20:22:25 +01:00
<option value="man">Man</option>
2015-12-07 18:15:34 +01:00
<option value="markdown" selected>Markdown (pandoc)</option>
2018-11-04 20:22:25 +01:00
<option value="gfm">Markdown (GitHub-flavored)</option>
2015-12-07 18:15:34 +01:00
<option value="markdown_phpextra">Markdown (PHP Markdown Extra)</option>
2017-10-30 01:05:06 +01:00
<option value="markdown_strict">Markdown (strict)</option>
2015-12-07 18:15:34 +01:00
<option value="mediawiki">MediaWiki</option>
2018-11-04 20:22:25 +01:00
<option value="markdown_mmd">MultiMarkdown</option>
2017-06-19 10:46:02 +02:00
<option value="muse">Muse</option>
2017-10-30 22:20:12 +01:00
<option value="native">Native (Pandoc AST)</option>
2015-12-07 18:15:34 +01:00
<option value="opml">OPML</option>
<option value="org">Org Mode</option>
<option value="rst">reStructuredText</option>
<option value="t2t">Txt2Tags</option>
2017-10-30 01:05:06 +01:00
<option value="textile">Textile</option>
<option value="tikiwiki">TikiWiki</option>
<option value="twiki">TWiki</option>
<option value="vimwiki">Vimwiki</option>
</select>
<br/>
<textarea id="text" maxlength="3000" rows="15"></textarea>
</div>
<div id="topane">
<label for="to">
to
</label>
<select id="to">
2017-10-30 01:05:06 +01:00
<option value="S5">S5</option>
<option value="asciidoc">AsciiDoc (original)</option>
<option value="asciidoctor">AsciiDoc (asciidoctor-flavored)</option>
2017-10-30 01:05:06 +01:00
<option value="beamer">LaTeX Beamer</option>
<option value="commonmark">CommonMark</option>
2015-12-07 18:15:34 +01:00
<option value="context">ConTeXt</option>
2017-10-30 01:05:06 +01:00
<option value="docbook4">DocBook v4</option>
<option value="docbook5">DocBook v5</option>
2022-08-18 06:39:22 +02:00
<option value="docx">Docx (Word)</option>
2015-12-07 18:15:34 +01:00
<option value="dokuwiki">DokuWiki</option>
<option value="dzslides">DZSlides</option>
2022-08-18 06:39:22 +02:00
<option value="epub2">EPUB v2</option>
<option value="epub3">EPUB v3</option>
2017-10-30 01:05:06 +01:00
<option value="haddock">Haddock markup</option>
2018-11-04 19:43:38 +01:00
<option value="html4">HTML 4</option>
<option value="html5" selected>HTML 5</option>
2015-12-07 18:15:34 +01:00
<option value="icml">ICML</option>
<option value="jats">JATS</option>
2019-06-12 07:24:32 +02:00
<option value="jira">Jira</option>
2017-10-30 01:05:06 +01:00
<option value="json">JSON</option>
<option value="ipynb">Jupyter Notebook (ipynb)</option>
2015-12-07 18:15:34 +01:00
<option value="latex">LaTeX</option>
2018-11-04 20:22:25 +01:00
<option value="man">Man</option>
<option value="ms">Ms</option>
2015-12-07 18:15:34 +01:00
<option value="markdown">Markdown (pandoc)</option>
2018-11-04 20:22:25 +01:00
<option value="gfm">Markdown (GitHub-flavored)</option>
2017-10-30 01:05:06 +01:00
<option value="markdown_phpextra">Markdown (PHP Markdown Extra)</option>
<option value="markdown_strict">Markdown (strict)</option>
<option value="mediawiki">MediaWiki</option>
2018-11-04 20:22:25 +01:00
<option value="markdown_mmd">MultiMarkdown</option>
2017-10-30 01:05:06 +01:00
<option value="muse">Muse</option>
2017-10-30 22:20:12 +01:00
<option value="native">Native (Pandoc AST)</option>
2022-08-18 06:39:22 +02:00
<option value="odt">ODT</option>
<option value="opendocument">OpenDocument</option>
2015-12-07 18:15:34 +01:00
<option value="opml">OPML</option>
2017-10-30 01:05:06 +01:00
<option value="org">Org Mode</option>
<option value="plain">Plain text</option>
2022-08-18 06:39:22 +02:00
<option value="pptx">Powerpoint</option>
2017-10-30 01:05:06 +01:00
<option value="revealjs">reveal.js</option>
<option value="rst">reStructuredText</option>
<option value="rtf">RTF</option>
<option value="slideous">Slideous</option>
2015-12-07 18:15:34 +01:00
<option value="slidy">Slidy</option>
<option value="tei">TEI</option>
2015-12-07 18:15:34 +01:00
<option value="texinfo">Texinfo</option>
2017-10-30 01:05:06 +01:00
<option value="textile">Textile</option>
<option value="zimwiki">ZimWiki</option>
</select>
<input type="checkbox" id="standalone" name="standalone">
<label for="standalone">Standalone
<a href="https://pandoc.org/MANUAL.html#option--standalone" target="_blank">(?)</a>
</label>
<br/>
<pre id="results"></pre>
</div>
</div>
</div>
<script>
"use strict";
function newpage() {
let input = document.getElementById("text").value;
let from = document.getElementById("from").value;
let to = document.getElementById("to").value;
let standalone = document.getElementById("standalone").checked ? true : false;
let href = window.location.href;
const URLparams = new URLSearchParams(Object.entries({text: input, from: from, to: to, standalone: standalone}));
window.location.href = href.replace(/([?].*)?$/,"?" + URLparams);
};
2022-08-18 06:39:22 +02:00
const binaryFormats = {
docx: { extension: "docx",
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
odt: { extension: "odt",
mime: "application/vnd.oasis.opendocument.text" },
pptx: { extension: "pptx",
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation" },
epub2: { extension: "epub",
mime: "application/epub+zip" },
epub3: { extension: "epub",
mime: "application/epub+zip" }
};
(function() {
const params = new URLSearchParams(window.location.search);
2022-08-18 06:15:50 +02:00
let text = params.get("text") || '"hello *world*"';
document.getElementById("text").value = text;
let from = params.get("from") || "markdown";
document.getElementById("from").value = from;
let to = params.get("to") || "html5";
document.getElementById("to").value = to;
let standalone = params.get("standalone") === "true";
document.getElementById("standalone").checked = standalone;
if (text && text != "") {
fetch("/cgi-bin/pandoc-server.cgi/version")
.then(response => response.text())
.then(restext =>
2022-08-18 06:39:22 +02:00
document.getElementById("version").textContent = restext
);
let params = { from: from, to: to, text: text, standalone: standalone };
// console.log(JSON.stringify(params));
2022-08-18 06:15:50 +02:00
let commandString = "pandoc"
+ " --from " + from + " --to " + to
+ (standalone ? " --standalone" : "");
document.getElementById("command").textContent = commandString;
fetch("/cgi-bin/pandoc-server.cgi", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify(params)
})
.then(response => response.text())
.then(restext => {
2022-08-18 06:39:22 +02:00
let binary = binaryFormats[to];
if (binary) {
document.getElementById("results").innerHTML =
'<a download="trypandoc.' + binary.extension +
'" href="data:' + binary.mime + ';base64,' + restext +
'">click to download trypandoc.' + binary.extension + '</a>';
} else {
document.getElementById("results").textContent = restext;
}
});
};
document.getElementById("convert").onclick = newpage;
document.getElementById("from").onchange = newpage;
document.getElementById("to").onchange = newpage;
document.getElementById("standalone").onchange = newpage;
})();
</script>
</body>
</html>