2025-04-12
Giving each post a width option in the yaml metadata to select between narrow for single-column English to wide for two-column translation posts.
Save Pandoc’s default template
pandoc --print-default-template=html5 > custom-template.html
Make one single change in
custom-template.html
:
- <body>
+ <body class="$if(width)$$width$$else$narrow-width$endif$">
Update your md2html
function to use
this template:
md2html() {
local args=(
# ... your existing args ...
"--template=custom-template.html" # Add this line
)
# ... rest of your function ...
}
Usage in markdown files:
---
title: My Post
width: wide-width # narrow-width (default) | medium-width | wide-width | full-width
---
<body>
tagKeep your custom-template.html
under version control so
it stays with your project. If you ever need to update it (e.g., when
upgrading Pandoc), just regenerate it and reapply your single-line
change.