问题
How to align all h1 headers of the pdf to center using pandoc with lua-filters?
I have the test.md file bellow:
<center>
# Chapter 1
</center>
<right>
## Sub-1-1
</right>
<left>
### Sub-1-2
</left>
<center>
# Chapter 2
</center>
<right>
## Sub-2-1
</right>
<left>
### Sub-2-2
</left>
And I need to align center all "Chapters" to center, all the "Sub--1" to right and all the "Sub--2" to left using tags as above, to stay like:
Chapter 1
Sub-1-1
Sub-1-2
Chapter 2
Sub-2-1
Sub-2-2
I can uppcase the "Chapters" with the follow filter.lua:
local text = require('text')
function Header(el)
if el.level == 1 then
return pandoc.walk_block(el, {
Str = function(el)
return pandoc.Str(text.upper(el.text))
end })
end
end
So I call the pandoc:
pandoc test.md -o test.pdf --pdf-engine=xelatex --lua-filter=./filter.lua
But I don't know how to align the things with lua-filters.
来源:https://stackoverflow.com/questions/64466021/how-to-align-text-using-pandoc-with-lua-filters