markdown to html via pandoc full page width
Asked Answered
R

2

6

I have a markdown file test.md

---
title: README TCC
numbersections: true
---

# README
sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm saldnmflasnfjlsanfjlnsajlfnjslnf sadfnasjlfdnlasd sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm sdfsafdasfdijmsldfnmlsnmkldfnmlsnmfdnmsaklm

which I convert into an html file via pandoc -s --toc ./test.md -o README.html --number-sections

This is the resulting README.html viewed in chrome:

enter image description here

But I want to let the text span the whole page!

Within README.hmtl the style of body is specified as:

body {
  margin: 0 auto;
  max-width: 36em;
  padding-left: 50px;
  padding-right: 50px;
  padding-top: 50px;
  padding-bottom: 50px;
  hyphens: auto;
  word-wrap: break-word;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

Adding min-width:80%; as an attribute, yields the desired behavior:

enter image description here

How can I make pandoc automatically generate a html that spans the whole page, when generating the document, i.e. include the min-width:80%; property?

Royo answered 22/7, 2022 at 10:3 Comment(2)
I think this might be a result of the fake data you are using, since each "word" is so long, I think this layout might just be the result of line-wrapping. Have you tried with a more traditional lorem-ipsum style fake data with shorter words?Carolynncarolynne
@Carolynncarolynne I adjusted my question, as you see, the text can span the full page, setting the right html style properties.Royo
H
2

Place the below snippet anywhere in your Markdown document:

``` {=html}
<style>
body { min-width: 80% !important; }
</style>
```

This will override the default min-width setting.

Homestretch answered 22/7, 2022 at 16:57 Comment(0)
A
0

Set the maxwidth via the YAML metadata block, i.e. add the following to the beginning of your markdown file:

```
maxwidth: 80%
```

source: https://pandoc.org/chunkedhtml-demo/6.2-variables.html.

You can also create a separate .yaml file and add it via the markdown command (as explained in the YAML metadata block documentation):

pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html
Auriga answered 17/6, 2024 at 5:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.