public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* YAML metadata block + HTML input file
@ 2021-12-07 19:09 Gregory D. Weber
       [not found] ` <91104b9d67992600aa9acc26fa32b2cfcde60056.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Gregory D. Weber @ 2021-12-07 19:09 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I'm having trouble with an HTML to HTML conversion using a template and YAML
metadata block.  Pandoc does not seem to recognize the YAML block in the HTML
input file, and then reports an error due to the missing $title$ variable.  If
the error is mine, I'd like to know what I did wrong here:

$ pandoc --version
pandoc 2.5
Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.7.7
......

$ pandoc --template=template.html -o output.html input.html
[WARNING] This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata,
  e.g. by using --metadata pagetitle="..." on the command line.
  Falling back to 'input'

A.  These are my files:

1.  template.html

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="UTF-8"/>
      <title>$title$</title>
    </head>

    <body>
      <h1>$title$</h1>
      <div>$body$</div>
    </body>
</html>

2.  input.html

---
title: Hello
---
<form id="form1"
  <p>Salvete, sodales.</p>
</form>

3.  output.html

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="UTF-8"/>
      <title></title>
    </head>

    <body>
      <h1></h1>
      <div>--- title: Hello ---
Salvete, sodales.</div>
    </body>
</html>

B.  So far, I'm able to work around this by putting the metadata variables in
their own file, *without* the "---" above and below, and using the --metadata-
file option.  And this seems to work also for ordinary template variables like
$speaker$, which are not metadata variables like $title$ -- though I don't
understand the distinction too clearly:

$ pandoc --template=template.html -o output2.html --metadata-file=input3.yaml
input2.html

1.  template.html

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="UTF-8"/>
      <title>$title$</title>
    </head>

    <body>
      <h1>$title$</h1>
      <div>Dixit $speaker$: $body$</div>
    </body>
</html>

1.  input3.html

<form id="form1"
  <p>Salvete, sodales.</p>
</form>

2.  input3.yaml

title: Hello
speaker: Marcus

3.  output2.html

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="UTF-8"/>
      <title>Hello</title>
    </head>

    <body>
      <h1>Hello</h1>
      <div>Dixit Marcus: Salvete, sodales.</div>
    </body>
</html>

(This is the desired and actual output.)



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-08  2:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 19:09 YAML metadata block + HTML input file Gregory D. Weber
     [not found] ` <91104b9d67992600aa9acc26fa32b2cfcde60056.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-12-07 20:19   ` John MacFarlane
     [not found]     ` <yh480kczm82mn9.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2021-12-07 21:02       ` Martin Hepp
     [not found]         ` <76E923B2-4D96-4654-8D11-B5B2A261C21F-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-12-08  2:44           ` John MacFarlane
2021-12-07 23:57       ` Gregory D. Weber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).