LaTeX writer: support beamer overlays (take 2)#9215
Open
Conversation
Pandoc elements with the `only=SPEC` attribute generate LaTeX code
wrapped in `\begin{onlyenv}<SPEC>...\end{onlyenv}
Unlike f0785a, this implementation is minimally invasive,
and is compatible with a wide range of generated LaTeX code,
including the `\Verb|` used by fenced code blocks.
The wrapping only occurs for beamer-LaTeX output,
never for plain LaTeX output
Now `visible`, `uncover`, and `visible` are supported, in addition to `only`. When multiple overlay-generating attributes are provided, nested environments are generated (instead of a warning).
8 tasks
Owner
|
I guess |
Contributor
Author
|
Yes, N.B. after writing this PR, I managed to get similar results with a lua filter: -- Convert ELEM{only=X} to \begin{onlyenv}<X>ELEM\end{onlyenv}
-- (and likewise for several other overlay types)
local overlays_supported = pandoc.List
{"only","uncover","visible","invisible","action","alert"}
local function tex_wrap(block_mode,pre,el,post)
return block_mode
and pandoc.Blocks
{pandoc.RawBlock("tex",pre), el, pandoc.RawBlock("tex",post)}
or pandoc.Inlines
{pandoc.RawInline("tex",pre), el, pandoc.RawInline("tex",post)}
end
local function wrap_in_overlays(block_mode,el)
for k,v in pairs(el.attributes) do
el = overlays_supported:includes(k)
and tex_wrap(block_mode,"\\begin{"..k.."env}<"..v..">",el,"\\end{"..k.."env}")
or el
end
return el
end
local function wrap_block(el) return wrap_in_overlays(true,el) end
local function wrap_inline(el) return wrap_in_overlays(false,el) end
return {{
-- These block elements have attributes
CodeBlock = wrap_block,
Div = wrap_block,
Figure = wrap_block,
Table = wrap_block,
-- These inline elements have attributes
Code = wrap_inline,
Image = wrap_inline,
Link = wrap_inline,
Span = wrap_inline,
}}So I'm no longer sure that this PR is worth merging. |
Contributor
Author
|
8 presentations later (half of these), a lua filter still covers my animation requirements. So I'm closing this PR as not-wanted. |
Owner
|
If you wouldn't mind keeping this open, it's still something I'd consider...it could be a useful feature in pandoc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a successor to #9203, with a different implementation.
This PR allows ergonomic beamer scripting, via attributes on pandoc elements.
only,visible,uncover,invisible] are interpreted specially by the beamer writerBlockorInlineelement\begin{XXXenv}<YYY>...\end{XXXenv},for each (special) attribute pair
(XXX,YYY)Example
I can write a presentation in markdown:
Then
pandoc src.md -o slides.pdf --to beamergenerates a 12-page slideshow:slides.pdf