From: Vittorio Romeo <vittorio.romeo.vee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Panflute filter: wrapping code block with docx custom style without losing syntax highlighting
Date: Fri, 15 May 2020 15:49:16 -0700 (PDT) [thread overview]
Message-ID: <7f65d550-17ce-474a-b830-31ff8b1d78b3@googlegroups.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1442 bytes --]
Hello, I am trying to write a filter to find all code blocks and wrap them
into a custom `.docx` style. This is what I tried:
if type(elem) == pf.CodeBlock:
return pf.Div(elem, attributes={'custom-style': 'Source Code
Boxed'})
However, that doesn't work - it seems that the syntax highlighting styles
override my desired `'Source Code Boxed'` style. I found a workaround, but
it is ugly, and loses all the syntax highlighting:
if type(elem) == pf.CodeBlock:
elemStr = pf.stringify(elem)
lines = [pf.LineItem(pf.Str(x)) for x in elemStr.splitlines()]
return pf.Div(pf.LineBlock(*lines),
attributes={ 'custom-style': 'Source Code Boxed'})
The above works (it surrounds my code block in a box in my final `.docx`
output), but all syntax highlighting is lost.
**Is there a way to achieve my desired result?** I would the code being
surrounded in a box (thanks to my `'Source Code Boxed'` style), but still
retain its syntax highlighting.
I have the same problem with TableCell, by the way.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7f65d550-17ce-474a-b830-31ff8b1d78b3%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 2521 bytes --]
next reply other threads:[~2020-05-15 22:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 22:49 Vittorio Romeo [this message]
[not found] ` <7f65d550-17ce-474a-b830-31ff8b1d78b3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-06-03 8:16 ` K4zuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7f65d550-17ce-474a-b830-31ff8b1d78b3@googlegroups.com \
--to=vittorio.romeo.vee-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).