2014-08-18 01:11:09 +02:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Try pandoc!</title>
|
2018-12-11 00:39:22 +01:00
|
|
|
<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]-->
|
2020-03-15 17:46:53 +01:00
|
|
|
<style>
|
2022-08-18 04:58:47 +02:00
|
|
|
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; }
|
2014-08-18 01:11:09 +02:00
|
|
|
div.alert { margin: 1em; }
|
2022-08-18 04:58:47 +02:00
|
|
|
pre#results { width: 100%; margin-top: 15px; min-height: 65vh; width: 44vw; }
|
2014-08-18 01:11:09 +02:00
|
|
|
footer { color: #555; text-align: center; margin: 1em; }
|
|
|
|
p.version { color: #555; }
|
2022-08-18 04:58:47 +02:00
|
|
|
.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; }
|
2014-08-18 01:11:09 +02:00
|
|
|
button#convert { vertical-align: bottom; }
|
2015-06-02 12:38:31 +02:00
|
|
|
pre#command { margin-top: 1em; background-color: transparent; border: none; }
|
2014-08-18 01:11:09 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2022-08-18 04:58:47 +02:00
|
|
|
<div class="container">
|
2014-08-18 01:11:09 +02:00
|
|
|
<div class="row">
|
2022-08-18 04:58:47 +02:00
|
|
|
<div id="title">
|
|
|
|
<h1>Try <a href="https://pandoc.org">pandoc</a>!</h1>
|
2015-06-02 12:08:03 +02:00
|
|
|
</div>
|
2022-08-18 04:58:47 +02:00
|
|
|
<div id="versioninfo">
|
|
|
|
<p class="version">v<span id="version"></span></p>
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
<div id="command">
|
2015-06-02 12:08:03 +02:00
|
|
|
<pre id="command"></pre>
|
|
|
|
</div>
|
2014-08-18 01:11:09 +02:00
|
|
|
</div>
|
|
|
|
<div class="row">
|
2022-08-18 04:58:47 +02:00
|
|
|
<div id="frompane">
|
|
|
|
<button id="convert">Convert</button>
|
2015-06-02 12:08:03 +02:00
|
|
|
|
2014-08-18 01:11:09 +02:00
|
|
|
<label for="from">
|
|
|
|
from
|
|
|
|
</label>
|
|
|
|
<select id="from">
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="bibtex">BibTeX</option>
|
|
|
|
<option value="biblatex">BibLaTeX</option>
|
2017-10-30 01:05:06 +01:00
|
|
|
<option value="commonmark">CommonMark</option>
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="commonmark_x">CommonMark (extended)</option>
|
2017-10-30 01:05:06 +01:00
|
|
|
<option value="creole">Creole</option>
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="csljson">CSL JSON</option>
|
2022-08-18 07:19:24 +02:00
|
|
|
<option value="csv">CSV</option>
|
2015-12-07 18:15:34 +01:00
|
|
|
<option value="docbook">DocBook</option>
|
2019-02-11 00:03:30 +01:00
|
|
|
<option value="dokuwiki">DokuWiki</option>
|
2022-08-18 07:19:24 +02:00
|
|
|
<option value="docx">Docx (Word)</option>
|
|
|
|
<option value="epub">EPUB</option>
|
2019-02-11 00:03:30 +01:00
|
|
|
<option value="fb2">FB2</option>
|
2015-12-07 18:15:34 +01:00
|
|
|
<option value="haddock">Haddock markup</option>
|
|
|
|
<option value="html">HTML</option>
|
2019-02-11 00:03:30 +01:00
|
|
|
<option value="jats">JATS</option>
|
2019-12-23 07:11:41 +01:00
|
|
|
<option value="jira">Jira</option>
|
2019-02-11 00:03:30 +01:00
|
|
|
<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>
|
2022-08-18 07:19:24 +02:00
|
|
|
<option value="odt">ODT</option>
|
2015-12-07 18:15:34 +01:00
|
|
|
<option value="opml">OPML</option>
|
|
|
|
<option value="org">Org Mode</option>
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="ris">RIS</option>
|
2014-08-18 01:11:09 +02:00
|
|
|
<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>
|
2017-06-26 08:41:51 +02:00
|
|
|
<option value="vimwiki">Vimwiki</option>
|
2022-08-18 07:19:24 +02:00
|
|
|
</select><br/>
|
|
|
|
<label for="loadfile">Load from file</label>
|
|
|
|
<input id="loadfile" type="file" />
|
2014-08-18 01:11:09 +02:00
|
|
|
<br/>
|
2022-08-18 17:09:50 +02:00
|
|
|
<textarea id="text" rows="15"></textarea>
|
2014-08-18 01:11:09 +02:00
|
|
|
</div>
|
2022-08-18 04:58:47 +02:00
|
|
|
<div id="topane">
|
2014-08-18 01:11:09 +02:00
|
|
|
<label for="to">
|
|
|
|
to
|
|
|
|
</label>
|
|
|
|
<select id="to">
|
2019-02-11 00:03:30 +01:00
|
|
|
<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>
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="bibtex">BibTeX</option>
|
|
|
|
<option value="biblatex">BibLaTeX</option>
|
2017-10-30 01:05:06 +01:00
|
|
|
<option value="commonmark">CommonMark</option>
|
2015-12-07 18:15:34 +01:00
|
|
|
<option value="context">ConTeXt</option>
|
2022-08-18 17:07:53 +02:00
|
|
|
<option value="csljson">CSL JSON</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>
|
2019-02-10 16:20:18 +01:00
|
|
|
<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>
|
2019-02-11 00:03:30 +01:00
|
|
|
<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>
|
2014-08-18 01:11:09 +02:00
|
|
|
<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>
|
2014-08-18 01:11:09 +02:00
|
|
|
<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>
|
2014-08-18 01:11:09 +02:00
|
|
|
<option value="rtf">RTF</option>
|
2022-08-18 07:19:24 +02:00
|
|
|
<option value="S5">S5</option>
|
2014-08-18 01:11:09 +02:00
|
|
|
<option value="slideous">Slideous</option>
|
2015-12-07 18:15:34 +01:00
|
|
|
<option value="slidy">Slidy</option>
|
2019-02-11 00:03:30 +01:00
|
|
|
<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>
|
2014-08-18 01:11:09 +02:00
|
|
|
</select>
|
2022-08-17 21:44:19 +02:00
|
|
|
<input type="checkbox" id="standalone" name="standalone">
|
|
|
|
<label for="standalone">Standalone
|
|
|
|
<a href="https://pandoc.org/MANUAL.html#option--standalone" target="_blank">(?)</a>
|
|
|
|
</label>
|
2022-08-18 17:07:53 +02:00
|
|
|
<input type="checkbox" id="citeproc" name="citeproc">
|
|
|
|
<label for="citeproc">Citeproc
|
|
|
|
<a href="https://pandoc.org/MANUAL.html#option--citeproc" target="_blank">(?)</a>
|
|
|
|
</label>
|
2014-08-18 01:11:09 +02:00
|
|
|
<br/>
|
2022-08-18 07:19:24 +02:00
|
|
|
<a id="permalink" title="link to this conversion" href="">permalink</a></br/>
|
2014-08-18 01:11:09 +02:00
|
|
|
<pre id="results"></pre>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-07 21:20:00 +02:00
|
|
|
|
|
|
|
<script>
|
|
|
|
"use strict";
|
|
|
|
|
2022-08-18 07:19:24 +02:00
|
|
|
var params = {
|
|
|
|
text: '"hello *world*"',
|
|
|
|
to: 'html5',
|
|
|
|
from: 'markdown',
|
2022-08-18 17:07:53 +02:00
|
|
|
standalone: false,
|
|
|
|
citeproc: false };
|
2022-08-18 07:19:24 +02:00
|
|
|
|
|
|
|
function permalink() {
|
2022-08-07 21:20:00 +02:00
|
|
|
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;
|
2022-08-18 17:07:53 +02:00
|
|
|
let citeproc = document.getElementById("citeproc").checked ? true : false;
|
2022-08-07 21:20:00 +02:00
|
|
|
let href = window.location.href;
|
2022-08-18 17:07:53 +02:00
|
|
|
const URLparams = new URLSearchParams(Object.entries({text: input, from: from, to: to, standalone: standalone, citeproc: citeproc}));
|
2022-08-18 07:19:24 +02:00
|
|
|
return href.replace(/([?].*)?$/,"?" + URLparams);
|
|
|
|
}
|
2022-08-07 21:20:00 +02:00
|
|
|
|
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" },
|
2022-08-18 07:19:24 +02:00
|
|
|
epub: { extension: "epub",
|
|
|
|
mime: "application/epub+zip" },
|
2022-08-18 06:39:22 +02:00
|
|
|
epub2: { extension: "epub",
|
|
|
|
mime: "application/epub+zip" },
|
|
|
|
epub3: { extension: "epub",
|
|
|
|
mime: "application/epub+zip" }
|
|
|
|
};
|
|
|
|
|
2022-08-18 18:58:24 +02:00
|
|
|
const binaryMimeTypes = {
|
|
|
|
["application/epub+zip"]: true,
|
|
|
|
["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]: true,
|
|
|
|
["application/vnd.openxmlformats-officedocument.presentationml.presentation"]: true,
|
|
|
|
["application/vnd.oasis.opendocument.text"]: true
|
|
|
|
};
|
|
|
|
|
2022-08-18 07:19:24 +02:00
|
|
|
function paramsFromURL() {
|
|
|
|
if (window.location.search.length > 0) {
|
|
|
|
const uparams = new URLSearchParams(window.location.search);
|
|
|
|
params.text = uparams.get("text") || "";
|
|
|
|
params.from = uparams.get("from") || "markdown";
|
|
|
|
params.to = uparams.get("to") || "html5";
|
|
|
|
params.standalone = uparams.get("standalone") === "true";
|
2022-08-18 17:07:53 +02:00
|
|
|
params.citeproc = uparams.get("citeproc") === "true";
|
2022-08-18 07:19:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 17:44:58 +02:00
|
|
|
function handleErrors(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw Error(response.statusText);
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2022-08-18 07:19:24 +02:00
|
|
|
function convert() {
|
|
|
|
let text = document.getElementById("text").value;
|
|
|
|
let from = document.getElementById("from").value;
|
|
|
|
let to = document.getElementById("to").value;
|
|
|
|
let standalone = document.getElementById("standalone").checked;
|
2022-08-18 17:07:53 +02:00
|
|
|
let citeproc = document.getElementById("citeproc").checked;
|
|
|
|
params = { text: text, from: from, to: to, standalone: standalone,
|
|
|
|
citeproc: citeproc };
|
2022-08-18 07:19:24 +02:00
|
|
|
|
2022-08-07 21:20:00 +02:00
|
|
|
if (text && text != "") {
|
2022-08-08 17:35:32 +02:00
|
|
|
fetch("/cgi-bin/pandoc-server.cgi/version")
|
2022-08-18 17:44:58 +02:00
|
|
|
.then(handleErrors)
|
|
|
|
.catch(error =>
|
|
|
|
document.getElementById("results").textContent = error
|
|
|
|
)
|
2022-08-07 21:20:00 +02:00
|
|
|
.then(response => response.text())
|
|
|
|
.then(restext =>
|
2022-08-18 06:39:22 +02:00
|
|
|
document.getElementById("version").textContent = restext
|
2022-08-07 21:20:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// console.log(JSON.stringify(params));
|
2022-08-18 06:15:50 +02:00
|
|
|
let commandString = "pandoc"
|
|
|
|
+ " --from " + from + " --to " + to
|
2022-08-18 17:07:53 +02:00
|
|
|
+ (standalone ? " --standalone" : "")
|
|
|
|
+ (citeproc ? " --citeproc" : "") ;
|
2022-08-18 06:15:50 +02:00
|
|
|
document.getElementById("command").textContent = commandString;
|
2022-08-08 17:35:32 +02:00
|
|
|
fetch("/cgi-bin/pandoc-server.cgi", {
|
2022-08-07 21:20:00 +02:00
|
|
|
method: "POST",
|
|
|
|
headers: {"Content-Type": "application/json"},
|
|
|
|
body: JSON.stringify(params)
|
|
|
|
})
|
|
|
|
.then(response => response.text())
|
|
|
|
.then(restext => {
|
2022-08-18 07:19:24 +02:00
|
|
|
let binary = binaryFormats[to];
|
|
|
|
if (binary) {
|
2022-08-18 06:39:22 +02:00
|
|
|
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;
|
|
|
|
}
|
2022-08-18 07:19:24 +02:00
|
|
|
document.getElementById("permalink").href = permalink();
|
2022-08-07 21:20:00 +02:00
|
|
|
});
|
|
|
|
};
|
2022-08-18 07:19:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
paramsFromURL();
|
|
|
|
document.getElementById("text").value = params.text;
|
|
|
|
document.getElementById("from").value = params.from;
|
|
|
|
document.getElementById("to").value = params.to;
|
|
|
|
document.getElementById("standalone").checked = params.standalone;
|
2022-08-18 17:07:53 +02:00
|
|
|
document.getElementById("citeproc").checked = params.citeproc;
|
2022-08-18 07:19:24 +02:00
|
|
|
|
|
|
|
document.getElementById("convert").onclick = convert;
|
|
|
|
document.getElementById("from").onchange = convert;
|
|
|
|
document.getElementById("to").onchange = convert;
|
|
|
|
document.getElementById("standalone").onchange = convert;
|
2022-08-18 17:07:53 +02:00
|
|
|
document.getElementById("citeproc").onchange = convert;
|
2022-08-18 07:19:24 +02:00
|
|
|
|
|
|
|
const fileInput = document.getElementById('loadfile');
|
|
|
|
|
|
|
|
// Listen for the change event so we can capture the file
|
|
|
|
fileInput.addEventListener('change', (e) => {
|
|
|
|
// Get a reference to the file
|
|
|
|
const file = e.target.files[0];
|
2022-08-18 18:58:24 +02:00
|
|
|
const mimetype = file.type;
|
|
|
|
let binary = binaryMimeTypes[mimetype];
|
|
|
|
|
2022-08-18 07:19:24 +02:00
|
|
|
// Encode the file using the FileReader API
|
|
|
|
const reader = new FileReader();
|
|
|
|
let inputtext = document.getElementById("text");
|
|
|
|
reader.onloadend = () => {
|
|
|
|
// Use a regex to remove data url part
|
2022-08-18 18:58:24 +02:00
|
|
|
console.log(mimetype);
|
2022-08-18 07:19:24 +02:00
|
|
|
if (binary) {
|
|
|
|
const base64String = reader.result
|
|
|
|
.replace('data:', '')
|
|
|
|
.replace(/^.+,/, '');
|
|
|
|
inputtext.value = base64String;
|
|
|
|
} else {
|
|
|
|
inputtext.value = reader.result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (binary) {
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
} else {
|
|
|
|
reader.readAsText(file);
|
|
|
|
}
|
|
|
|
});
|
2022-08-18 18:58:24 +02:00
|
|
|
|
2022-08-18 07:19:24 +02:00
|
|
|
convert();
|
|
|
|
|
2022-08-07 21:20:00 +02:00
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
|
2014-08-18 01:11:09 +02:00
|
|
|
</body>
|
|
|
|
</html>
|