From 30277dc2f21785f4ebed48896f2032cbce66e321 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 25 Aug 2022 19:48:01 -0700 Subject: trypandoc: allow custom templates. --- trypandoc/examples.js | 24 +++++++++++++++++++++++- trypandoc/index.html | 22 ++++++++++++---------- trypandoc/trypandoc.js | 23 ++++++++++++++++++++++- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/trypandoc/examples.js b/trypandoc/examples.js index abe7e5eca..a1f5a3bbe 100644 --- a/trypandoc/examples.js +++ b/trypandoc/examples.js @@ -685,7 +685,29 @@ These are all pretty interesting facts. from: 'latex', to: 'docbook5', ['html-math-method']: 'mathml', - standalone: true } + standalone: true }, + + ["Custom template"]: + { text: `--- +keywords: +- bee +- ant +- ladybug +author: E. N. Tymologist +title: Some bugs +... + +This is a book about bugs.`, + from: 'markdown', + to: 'html5', + standalone: true, + template: `

$title$

+

by $author$

+

Keywords: $for(keywords)$$it$$sep$; $endfor$

+
+$body$ +
+` } } diff --git a/trypandoc/index.html b/trypandoc/index.html index 30420dda6..eb82c8636 100644 --- a/trypandoc/index.html +++ b/trypandoc/index.html @@ -11,7 +11,7 @@ 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; } + textarea { height: auto; font-family: monospace; font-size: 10pt; margin-top: 15px; min-height: 45vh; width: 44vw; } div.alert { margin: 1em; } div#errors { width: 100%; color: red; font-weight: 600; padding-top: 6pt; padding-bottom: 6pt; display: none; } pre#results { width: 100%; margin-top: 0; min-height: 65vh; width: 44vw; } @@ -31,6 +31,7 @@ span.filename { } #convert { margin-left: 0; } div.file textarea { margin-top: 0; } + #customtemplate { display: none; } @@ -101,22 +102,23 @@ Input -
- - +

+
+ + +
+ +