From: Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Customize CodeBlock font size in docx
Date: Tue, 11 Jul 2023 15:22:01 +0000 [thread overview]
Message-ID: <ZK1zmaESgJ2XF6ON@localhost> (raw)
In-Reply-To: <a99ab2f9-e808-4d9d-a510-aea4e9348b46n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Mmh, you're right, the text in the Source Code paragraphs has the character style Verbatim Char, which makes impossible to change its size. Conceptually, this behaviour is right: the problem is more that, in the DOCX format (or some of its implementations, such as Word and LibreOffice), the font properties set in a paragraph style don't take precedence over those of the linked character style, which I find rather illogical.
If you don't want syntax highlighting in inline code, you can write a filter to transform Code elements into Spans with a custom style. Then you will be able to set this custom style to a monospaced font at the normal size and to adapt freely the Verbatim Char style to your needs for code blocks.
Le Tuesday 11 July 2023 à 07:00:23AM, Sylvain Hubert a écrit :
> I can't find Verbatim Char in my MS word for Mac even in "All styles".
>
> After unzipping the docx file and inspecting both style.xml and document.xml, I
> found that "Source Code" is a paragraph style, linking to "Verbatim Char" which
> is character style. This probably explains why I'm not seeing Verbatim Char in
> "All styles".
>
> But on the other hand, this also means that Verbatim Char is not
> differentiating inline code and fenced code blocks. Pandoc does not seem to
> differentiate them in any ways without filters.
>
> On Tuesday, 11 July 2023 at 20:51:39 UTC+8 mf wrote:
>
> Sorry for the mistake, please read "'Source Code' paragraph style"
> instead of "'Code Block' paragraph style".
>
> I have no MS Word, I'm using Softmaker Office, but you can see the
> styles anyway.
> In the screenshot I see that you are displaying only the styles in use,
> please show all the styles and you'll see "Verbatim Char" too.
>
> In your example I see "NormalTok", "OperatorTok", "PreprocessorTok" that
> are character styles derived from "Verbatim Char". You see those because
> you specified the language of the block code, so you get syntax
> highlighting.
>
>
> Il 11/07/23 14:24, Sylvain Hubert ha scritto:
> > I can only find the "Source Code" style but no "Code Block", even in
> > "All styles". Please find attached the screenshot.
> >
> > Could it have anything to do with the version of MS word?
> > pandoc-code-docx.png
> >
> >
> > On Tuesday, 11 July 2023 at 19:14:06 UTC+8 mf wrote:
> >
> > There are two styles:
> >
> > - "Code Block" paragraph style, that I made smallcaps in my example
> >
> > - "Verbatim Char" character style, that I made blue
> >
> > I did not check, but I suspect inline code is blue but not smallcaps,
> > because it should take only the "Verbatim Char" character style.
> >
> > You should also notice that "Verbatim Char" has many derived styles for
> > syntax highlighting, that are used once you specify the language of
> > your
> > code block.
> >
> > So if you want to change only code blocks, you'll work on the "Code
> > Block" paragraph style, leaving the character styles untouched.
> >
> >
> >
> > Il 11/07/23 11:39, Sylvain Hubert ha scritto:
> > > Thanks, I do see the "Source Code" style now.
> > >
> > > But changing it seems to affect not just code blocks but inline
> > code as
> > > well, which is unwanted:
> > >
> > > pandoc -o code-block.docx <<<'
> > > `inline code`
> > >
> > > ```c
> > > #include <stdio.h>
> > > int main() {
> > > return 0;
> > > }
> > > ```
> > > '
> > >
> > > Is it possible to customize code blocks *only*?
> > > On Tuesday, 11 July 2023 at 15:17:03 UTC+8 Bastien DUMONT wrote:
> > >
> > > pandoc -o code-block.docx <<< '
> > > ~~~
> > > print("Hello World!")
> > > ~~~
> > > '
> > >
> > > You get a document with a code block that you can copy-paste into
> > > your reference doc and customize there (its Paragraph style).
> > >
> > > Le Monday 10 July 2023 à 11:51:26PM, Sylvain Hubert a écrit :
> > > > Thanks, but I can't find any code block in the default reference
> > > docx.
> > > >
> > > > On Saturday, 1 July 2023 at 18:34:39 UTC+8 mf wrote:
> > > >
> > > > Il 01/07/23 11:07, Sylvain Hubert ha scritto:
> > > > > Hi all,
> > > > >
> > > > > Does anyone know how to reduce the font size of code blocks in
> > > the docx
> > > > > output?
> > > >
> > > > You may try this:
> > > >
> > > > - export the code block in a, say, reference.docx
> > > >
> > > > - open reference.docx with Word and customize the paragraph style
> > > of the
> > > > code block, then save
> > > >
> > > > - export again the code block in another docx file, using the
> > option
> > > > --reference-doc=reference.docx
> > > >
> > > > Pandoc should use the styles it finds in reference.docx, so the
> > > block
> > > > code should look the way you customized it with Word.
> > > >
> > > >
> > > > >
> > > > > I know I could customize the Verbatim style in the reference
> > doc,
> > > > > but that would also unwantedly affect the inline code.
> > > > >
> > > > > Ideally it should be done with custom styles, without too much
> > > hacks of
> > > > > raw docx.
> > > > >
> > > > > Thanks!
> > > > >
> > > >
> > > > --
> > > > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > > > To view this discussion on the web visit
> > > [2][1]https://groups.google.com/d/msgid/
> > <[2]https://groups.google.com/d/msgid/>
> > > <[3]https://groups.google.com/d/msgid/
> > <[4]https://groups.google.com/d/msgid/>>
> > > >
> > >
> > pandoc-discuss/cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%[5]
> 40googlegroups.com <[6]http://40googlegroups.com> <[7]http://
> 40googlegroups.com <[8]http://40googlegroups.com>>.
> > > >
> > > > References:
> > > >
> > > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > > [2]
> > >
> > [9]https://groups.google.com/d/msgid/pandoc-discuss/
> cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&
> utm_source=footer <[10]https://groups.google.com/d/msgid/pandoc-discuss/
> cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&
> utm_source=footer> <[11]https://groups.google.com/d/msgid/pandoc-discuss/
> cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&
> utm_source=footer <[12]https://groups.google.com/d/msgid/pandoc-discuss/
> cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&
> utm_source=footer>>
> > >
> > > --
> > > 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > <mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> > > To view this discussion on the web visit
> > >
> > [13]https://groups.google.com/d/msgid/pandoc-discuss/
> 7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com <[14]https://
> groups.google.com/d/msgid/pandoc-discuss/
> 7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com> <[15]https://
> groups.google.com/d/msgid/pandoc-discuss/
> 7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com?utm_medium=email&
> utm_source=footer <[16]https://groups.google.com/d/msgid/pandoc-discuss/
> 7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com?utm_medium=email&
> utm_source=footer>>.
> >
> > --
> > 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > <mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> > To view this discussion on the web visit
> > [17]https://groups.google.com/d/msgid/pandoc-discuss/
> 1244cd1b-72a6-4c8b-9b15-830bbd36ab6dn%40googlegroups.com <[18]https://
> groups.google.com/d/msgid/pandoc-discuss/
> 1244cd1b-72a6-4c8b-9b15-830bbd36ab6dn%40googlegroups.com?utm_medium=email&
> utm_source=footer>.
>
> --
> 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 [19]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [20]https://groups.google.com/d/msgid/
> pandoc-discuss/a99ab2f9-e808-4d9d-a510-aea4e9348b46n%40googlegroups.com.
>
> References:
>
> [1] https://groups.google.com/d/msgid/
> [2] https://groups.google.com/d/msgid/
> [3] https://groups.google.com/d/msgid/
> [4] https://groups.google.com/d/msgid/
> [5] http://40googlegroups.com/
> [6] http://40googlegroups.com/
> [7] http://40googlegroups.com/
> [8] http://40googlegroups.com/
> [9] https://groups.google.com/d/msgid/pandoc-discuss/cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&utm_source=footer
> [10] https://groups.google.com/d/msgid/pandoc-discuss/cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&utm_source=footer
> [11] https://groups.google.com/d/msgid/pandoc-discuss/cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&utm_source=footer
> [12] https://groups.google.com/d/msgid/pandoc-discuss/cff22eb0-a9d4-4e03-aa77-b83c42c04a57n%40googlegroups.com?utm_medium=email&utm_source=footer
> [13] https://groups.google.com/d/msgid/pandoc-discuss/7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com
> [14] https://groups.google.com/d/msgid/pandoc-discuss/7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com
> [15] https://groups.google.com/d/msgid/pandoc-discuss/7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com?utm_medium=email&utm_source=footer
> [16] https://groups.google.com/d/msgid/pandoc-discuss/7e333365-fe50-4652-8274-aa83c66e213an%40googlegroups.com?utm_medium=email&utm_source=footer
> [17] https://groups.google.com/d/msgid/pandoc-discuss/1244cd1b-72a6-4c8b-9b15-830bbd36ab6dn%40googlegroups.com
> [18] https://groups.google.com/d/msgid/pandoc-discuss/1244cd1b-72a6-4c8b-9b15-830bbd36ab6dn%40googlegroups.com?utm_medium=email&utm_source=footer
> [19] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [20] https://groups.google.com/d/msgid/pandoc-discuss/a99ab2f9-e808-4d9d-a510-aea4e9348b46n%40googlegroups.com?utm_medium=email&utm_source=footer
--
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/ZK1zmaESgJ2XF6ON%40localhost.
prev parent reply other threads:[~2023-07-11 15:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-01 9:07 Sylvain Hubert
[not found] ` <71cbadfc-e399-4cd2-becd-95fc94278adfn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-01 10:20 ` Bastien DUMONT
2023-07-01 10:34 ` mf
[not found] ` <3fe3c11f-bed0-fa56-4c2a-a4a96793f4a3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-07-11 6:51 ` Sylvain Hubert
[not found] ` <cff22eb0-a9d4-4e03-aa77-b83c42c04a57n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-11 7:16 ` Bastien DUMONT
2023-07-11 9:39 ` Sylvain Hubert
[not found] ` <7e333365-fe50-4652-8274-aa83c66e213an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-11 11:13 ` mf
[not found] ` <782d9773-1c50-9b79-b05f-361a9df87127-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-07-11 12:24 ` Sylvain Hubert
[not found] ` <1244cd1b-72a6-4c8b-9b15-830bbd36ab6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-11 12:51 ` mf
[not found] ` <5303aa80-f729-f4c2-0e38-96e3d90a80af-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-07-11 14:00 ` Sylvain Hubert
[not found] ` <a99ab2f9-e808-4d9d-a510-aea4e9348b46n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-07-11 15:22 ` Bastien DUMONT [this message]
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=ZK1zmaESgJ2XF6ON@localhost \
--to=bastien.dumont-vwifzpto/vqstnjn9+bgxg@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).