Thanks Albert!
I really appreciate you looking at this. When I run the above, I get this error:
Error running filter admonitions.lua:
admonitions.lua:10: attempt to index a nil value (local 'opts')
stack traceback:
admonitions.lua:10: in main chunk
Do I need to specify something in the command line? I'm running the build like so:
asciidoctor -b docbook -o - $PAGE | pandoc --markdown-headings=atx --shift-heading-level-by=1 --wrap=none -t markdown+backtick_code_blocks --lua-filter=admonitions.lua -f docbook - > ./docs/$PAGE.md
Aidan Reilly <aireilly-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> Trying this, but it's just passing the text of the admonition block
> through
The order of spaces and newline in the replacement was switched. After
some playing around, this is the filter I came up with:
``` lua
local admonitions = {
warning = '!!! warning',
note = '!!! note',
tip = '!!! tip',
important = '!!! important',
caution = '!!! caution'
}
local opts = PANDOC_WRITER_OPTIONS -- reuse options to render snippets
opts.columns = opts.columns - 4 -- admons are indented by four spaces
opts.template = nil -- render a snippet
function Div (div)
local admonition_text = admonitions[div.classes[1]]
if not admonition_text then return nil end -- not an admonition: bail
local md = admonition_text .. '\n' ..
pandoc.write(pandoc.Pandoc(div.content), 'markdown', opts)
return pandoc.RawBlock(
'markdown',
md:gsub('\n*$', '') -- remove trailing newlines
:gsub('\n', '\n ') -- indent block
)
end
```
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
--
You received this message because you are subscribed to a topic in the Google Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/65G0Kuih1wA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87a6556cg2.fsf%40zeitkraut.de.
--