3

I want to set the page bgcolor through markdown.

Is there any way besides explicitly including, say, <body bgcolor="#336655"> in the .md file? In particular, this seems to be implemented incorrectly. E.g. the following minimal file:

% Page Title

<body bgcolor="#336655">

## Some Body

Produces the following HTML file (through pandoc -s -o test.html test.md)

<!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>Page Title</title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<div id="header">
<h1 class="title">Page Title</h1>
</div>
<body bgcolor="#336655">
<h2 id="some-body">Some Body</h2>
</body>
</html>

In particular, the <body> tag I included did not overwrite the main <body> tag produced, as I'd intended (closing with </body> in the markdown doesn't change this).

Placing the <body> tag prior to the % Page Title line shuts down the interpretation of that line as the page title -- it just formats as % Page Title in plain text.

Is there no way to control the overall page background in markdown?

mb21
  • 34,845
  • 8
  • 116
  • 142
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198

2 Answers2

5

You should change the pandoc template for that and insert the needed CSS. Don't do styling in HTML, it's not the 90s anymore...

$ pandoc -D html > template.html

edit it to include:

<style type="text/css">
  body {
    background-color: #336655;
  }
</style>

then

$ pandoc -s --template template.html -o output.html input.md
mb21
  • 34,845
  • 8
  • 116
  • 142
1

In multimarkdown you can supply a link to a CSS file to style the markdown as part of the markdown file.

MULTIMARKDOWN

Title: A page with a defined style
CSS: myStyle.css

# Text Header #

Lorem ipsum dolor sit amet,

- consectetuer adipiscing elit.

- Aliquam turpis. Nullam lobortis cursus nulla.

- Vestibulum ante ipsum primis in faucibus orci luctus et

- ultrices posuere cubilia Curae; Cras facilisis rhoncus ante.

    - In ut neque. Maecenas iaculis tempor massa. Sed quam wisi,

    - volutpat in, commodo vitae, accumsan et, nisl.

- Donec magna quam, commodo vitae, rhoncus a, luctus vitae, orci.
- Praesent nonummy mi facilisis tortor. Praesent suscipit. Donec laoreet dignissim justo. Nullam ut purus ac leo sollicitudin accumsan. Fusce et quam.


******************************

#### Date Created :: Monday 23 June 2014 ####

******************************

CSS - extracting just the body settings

body{
    font-family: helvetica, arial, freesans, clean, sans-serif;
    color: #333;
    background-color: red;
    border-color: #999999;
    border-width: 2px;
    line-height: 1.5;
    text-align:left;
}

OUTPUT

enter image description here

jwpfox
  • 5,124
  • 11
  • 45
  • 42