I am trying to take a markdown file that looks like this (this is from a pandoc
conversion of a Word document):
# Standard 1.1
## Narrative
::: {custom-style="Body Text"}
Please see artifact 1 ([Artifact 1]{custom-style="Link to Artifact"}). You can also
add references here as links ([[This is a reference]{custom-style="Hyperlink"}](https://www.website.link/path_to/reffile.pdf)).
:::
## Conclusion
::: {custom-style="Body Text"}
This is my conclusion.
:::
## Sources
[All sources will be automatically listed here. Do not modify this
section.]{custom-style="Sources"}
and convert it to something like this (this would be HTML or PDF as the real output, but this is what the equivalent Markdown would be):
# Standard 1.1
## Narrative
::: {custom-style="Body Text"}
Please see artifact 1 ([Artifact 1]{custom-style="Link to Artifact"}). You can also
add references here as links ([[This is a reference]{custom-style="Hyperlink"}](https://www.website.link/path_to/reffile.pdf)).
:::
## Conclusion
::: {custom-style="Body Text"}
This is my conclusion.
:::
## Sources
- [Artifact 1](./path_to/Artifact-1.pdf)
- [This is a reference](./path_to/reffile.pdf)
using Quarto (with Pandoc and a Lua extension in the background).
My extension captures the custom-styles Link to Artifact
and Hyperlink
(which show up in Span elements) and converts them to Link elements (well, it does a lot more, but that is the important part for this question). When that conversion is complete, I save the link in a global table. When I encounter the Sources
custom-style, I want to dump out that table as an unordered list (later I will output as either an ordered or unordered list depending on configuration).
This is where I am running into trouble. It seems my table is a Block element and Span is an Inline. How do I convert this table of links into an inline element that will work for both HTML and PDF?
I have tried to convert it using pandoc.utils.blocks_to_inlines
, RawInline
, RawBlock
, etc. Obviously, none of those worked. I can get the list of links in HTML by creating HTML code and just concatenating all the rows into a string and outputting a RawInline
. But that does not solve my PDF problem.
While I have figured much of this out, I am still trying to get my head wrapped around how Pandoc and Lua really work. Any help would be greatly appreciated!