holmeswatson
holmeswatson

Reputation: 1005

How to produce custom metadata html tags from markdown with pandoc

I am trying to use pandoc to convert a markdown file to html, but my custom metadata tags are not being generated.

markdown

---
title: How to blah blah
othertitle : How

...

#Other stuff { .intro}
Stuff

generated html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title>How to blah blah</title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<div id="header">
<h1 class="title">How to blah blah</h1>
</div>
<div id="other-stuff" class="section level1 intro">
<h1>Other stuff</h1>
<p>Stuff</p>
</div>
</body>
</html>

Only title is generated and not other title.

The command I run is

pandoc -o s.html --section-divs s.md -s

Any help appreciated

Tom

Upvotes: 4

Views: 2017

Answers (1)

holmeswatson
holmeswatson

Reputation: 1005

Figured it out, you have to create a custom template that looks for your tags and formats them for the output.

Easy way to do this is run this command to get the default html template, create your own template file and copy the output and add your own tags.

pandoc -D html

Then run pandoc like this

pandoc -o output.html -s input.html --template yourTemplate

Upvotes: 4

Related Questions