* Prevent audio/video resources in markdown/html to be dropped during LaTeX conversion
@ 2019-03-28 11:15 Alexander Neumann
[not found] ` <e81e7582-d009-4b7f-a942-9f721e767395-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Neumann @ 2019-03-28 11:15 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1708 bytes --]
Hello,
I have documents written in markdown and HTML and would like to convert
them into LaTeX. Since markdown has no native support for media files such
as audio and video, I had to make use of <audio> and <video> tags for this.
During the conversion to TeX, these "RawBlock" elements are completely
ignored.
---
$ cat test.md
## Paragraph
A video below.
<video controls>
<source src="video.mp4" type="video/mp4">
</video>
More text.
---
pandoc --to latex test.md --verbose
[INFO] Not rendering RawBlock (Format "html") "<video controls>"
[INFO] Not rendering RawBlock (Format "html") "<source src=\"video.mp4\"
type=\"video/mp4\">"
[INFO] Not rendering RawBlock (Format "html") "</video>"
\hypertarget{paragraph}{%
\subsection{Paragraph}\label{paragraph}}
A video below.
More text.
---
I do not necessarily need videos in LaTeX (even though it might be handy
for beamer presentations). I am just wondering if there is a way to
compatibly annotate placeholder images or such a like. Or maybe some pandoc
filters/template rules that replace <video> / <audio> blocks with (linked)
thumbnails.
Best regards,
Alex
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e81e7582-d009-4b7f-a942-9f721e767395%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 2574 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prevent audio/video resources in markdown/html to be dropped during LaTeX conversion
[not found] ` <e81e7582-d009-4b7f-a942-9f721e767395-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-03-28 13:44 ` Jesse Rosenthal
[not found] ` <87d0mb9kqz.fsf-4GNroTWusrE@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Jesse Rosenthal @ 2019-03-28 13:44 UTC (permalink / raw)
To: Alexander Neumann, pandoc-discuss
Alexander Neumann <aleneum-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> I am just wondering if there is a way to compatibly annotate
> placeholder images or such a like. Or maybe some pandoc
> filters/template rules that replace <video> / <audio> blocks with
> (linked) thumbnails.
Sure -- a filter could do this. Something like following (call it
script.lua):
~~~
function RawBlock (blk)
if FORMAT == "latex" then
if blk.format == "html" then
if blk.text == "<video controls>" then
return pandoc.RawBlock("latex", "\\begin{environment}")
elseif blk.text == "</video>" then
return pandoc.RawBlock("latex", "\\end{environment}")
else
local _, fp, _ = string.match(blk.text, "(<source src=\")([^\"]+)(.+)")
if fp then
return pandoc.RawBlock("latex", fp)
end
end
end
end
end
~~~
Given your test.md, we'd get:
~~~
$ pandoc test.md -t latex --lua-filter=script.lua
\hypertarget{paragraph}{%
\subsection{Paragraph}\label{paragraph}}
A video below.
\begin{environment}
video.mp4
\end{environment}
More text.
~~~
I do a bit of substitution for the center block (you can look up some
lua docs on it) and make up an environment name for it. Remember, in a
lua filter, if the function doesn't return anything, it leaves the
original untouched. Also, the opening FORMAT conditional makes it so it
only does this for LaTeX output.
There's probably a better way to do this than with the nested if-thens,
but this should get you started.
Best,
Jesse
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Prevent audio/video resources in markdown/html to be dropped during LaTeX conversion
[not found] ` <87d0mb9kqz.fsf-4GNroTWusrE@public.gmane.org>
@ 2019-05-13 12:18 ` Alexander Neumann
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Neumann @ 2019-05-13 12:18 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 2011 bytes --]
Hi Jesse,
thank you for your reply and your nice examples. Lua filters are indeed a
nice way to deal with this.
Since I posted my question I have used lua filters to exclude notes and
other markup not intended for the final document.
I had to solve the described situation otherwise though since I realized I
had more conditions than I had previously stated here.
Specifically, the solution has to work with the pandoc filter
`pandoc-crossref`.
A call like `pandoc -t markdown --lua-filter html_to_md.lua -F
pandoc-crossref test.md` does not resolve the reference while adding the
result of `html_to_md.lua` into the source file seems to work fine.
I could not figure out how to adjust the order of filters probably to deal
with this.
Alternatively, I could have called pandoc multiple times.
I ended up (mis)using the multifigure syntax of pandoc-crossref:
```
Some text that refers to [@fig:figure_id].
<div id="fig:figure_id" class="subfigures">
![](vid/test.png)<video controls src="vid/test.mp4"></video>
A caption that describes the figure
</div>
```
This way, I was able embed videos in HTML by overlaying the thumbnail image
with the actual video (via CSS) and have a resolved figure and references
in the LaTeX export when the RawBlock is filtered out.
If I plan to use more than thumbnails in the LaTeX export, I'd go the way
you have suggested with LaTeX environments.
Thanks again for your feedback,
Alex
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/dace53bf-9d2c-4b06-8a13-97a5654e956c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 2765 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-13 12:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 11:15 Prevent audio/video resources in markdown/html to be dropped during LaTeX conversion Alexander Neumann
[not found] ` <e81e7582-d009-4b7f-a942-9f721e767395-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-03-28 13:44 ` Jesse Rosenthal
[not found] ` <87d0mb9kqz.fsf-4GNroTWusrE@public.gmane.org>
2019-05-13 12:18 ` Alexander Neumann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).