Lua scripting: set dir attribute to auto by default #11061
-
I'm trying to write a filter for #10014 that adds the $ pandoc -f markdown -t html -L all_dir_auto.lua Where the script is function Para(elem)
elem.attributes.dir = 'auto'
return elem
end But I get |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Try this: function Para(elem)
local inlines = pandoc.List(elem.content)
inlines:insert(1, pandoc.RawInline('html', '<p dir="auto">'))
inlines:insert(pandoc.RawInline('html', '</p>'))
return pandoc.Plain(inlines)
end (you may also write |
Beta Was this translation helpful? Give feedback.
-
Thank you. That was what I needed. I wrote an additional filter for headers too. Hopefully this is robust enough function Header(elem)
local inlines = pandoc.List(elem.content)
inlines:insert(1, pandoc.RawInline('html', '<h' .. elem.level .. ' dir="auto">'))
inlines:insert(pandoc.RawInline('html', '</h' .. elem.level .. '>'))
return pandoc.Plain(inlines)
end
function Para(elem)
local inlines = pandoc.List(elem.content)
inlines:insert(1, pandoc.RawInline('html', '<p dir="auto">'))
inlines:insert(pandoc.RawInline('html', '</p>'))
return pandoc.Plain(inlines)
end |
Beta Was this translation helpful? Give feedback.
-
I just found this to be unnecessary as there is a css attribute for this:
|
Beta Was this translation helpful? Give feedback.
I just found this to be unnecessary as there is a css attribute for this:
from: https://stackoverflow.com/a/72463737