11

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?

2
  • 1
    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? Commented Jul 22, 2022 at 10:06
  • @DBS I adjusted my question, as you see, the text can span the full page, setting the right html style properties. Commented Jul 22, 2022 at 10:17

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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

1 Comment

Can you do it on the command line without a separate file, entering it in the command directly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.