From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/25207 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Vittorio Romeo Newsgroups: gmane.text.pandoc Subject: Panflute filter: wrapping code block with docx custom style without losing syntax highlighting Date: Fri, 15 May 2020 15:49:16 -0700 (PDT) Message-ID: <7f65d550-17ce-474a-b830-31ff8b1d78b3@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_755_1520942239.1589582956800" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="78540"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCO3NDEYZQHRB3NY7T2QKGQEAAIAKRY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat May 16 00:49:22 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f184.google.com ([209.85.167.184]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jZj8r-000KJO-2C for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 16 May 2020 00:49:21 +0200 Original-Received: by mail-oi1-f184.google.com with SMTP id l2sf2058794oih.19 for ; Fri, 15 May 2020 15:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=yNNO6IRTykDP7rraL7V/sjNgXwB83N9B8JdIuXfnmfA=; b=ksNZbbxkgqJEtTow6IJ0T4gbRcoeLbsbTyWkLxSro2hJSiFfW1+YY1YhpS1uUq71ye p0SVse7We037iki86pJoJcrF8uFpvKCJINeNowRCQysRB6pIWvMYJIjsGiHLEl589hf2 PaYOmSCPpHyHcH9SKdm363zheGJlD4IwhZY5Xwc62MDTHeV3dlmgOrDorVQH0tdggdva 5eu4P5vvZIOFSvMROfZvaXof6VKx6MvIVGSN/MQJpArYIRYOHovsGNFg09Q49QWbICCX e4hXBLsyl0WM0DuzMs1sXb/hsQfXpXMlRWoqxk95y1Z2c86zZUXar/Wzla/vVg0jRAyQ JdTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:subject:mime-version:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=yNNO6IRTykDP7rraL7V/sjNgXwB83N9B8JdIuXfnmfA=; b=gig9c5ucwgQ24PUjYXh3WYMNhaKxGIRzSXSwjTFNMaTIFJgWBcDvaZuGmHKQLZzsQ9 8LZfBxT051lDq69u1Ukh+crqGI4i4/vsEQ7IgdImM1LQNN8RS7Yvlgnr7Tx+VhWd3ea+ dnP4JC9f0xLmS8St3WbkVcQGfS+48i/B7fDfLP3RwKKPJ+HIT3k2cwf/5S/JIrhQlw2k /vDRp+zOaiPW1PGaSDKeoo0Ca0I/lXIWqf6x4lIo/XsbcEzQrke215N2vj6dqvj2sOsJ DWBBBlc/Y18p0/TxXBlK/bjVtYSWeA0msvro3nb/W21Ww+ZCiEtl8yw9lcCGuDZQVvIR 9HOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=yNNO6IRTykDP7rraL7V/sjNgXwB83N9B8JdIuXfnmfA=; b=JD8TRZKvkPM9Vy1Okd0wiUskfxXQ7RvsP9sp7LrudXJZocOtzad2a9qek874TvMiwq G5CthaZncSHH6IWfoE/HM+/xaMy3YbXDiCasMJfq1kuLyEXR81YPqHbBMk1ns5gWktBg 3bCG/eMQam1FaqBUeKrUgXt05gPnmB/zkvN9b7sDbqWiRrc1a1QF3MCqtCRMGw3riLHB dCfMEhy4c7taL3QjwiZdR3DmL15nh3/T4tx++GbCUbifJYZY11n/egvd3m7qfr4/uNxm DwkOo4z9KBb0rVRDtaWEe3pZrqBQxN1VUKsmWY9GYhFdVd2GyZVLjjD90AqJJQ+r+pD1 /Sew== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532V3/6bCpBlScAi6OIOSL6Quydant2hPEPINcglamEnGf5jmw+f j9yrYvmLGVM9ZU7OlHUc0tE= X-Google-Smtp-Source: ABdhPJwH0eFSKjnjfZ8gymljnzPtYlAt9odbHXVgr6tO0XHd0J3qXCBpGXmp4jN6mGBlUCAAEJyq4A== X-Received: by 2002:aca:dd8b:: with SMTP id u133mr3562132oig.55.1589582960086; Fri, 15 May 2020 15:49:20 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:784c:: with SMTP id c12ls817040otm.11.gmail; Fri, 15 May 2020 15:49:17 -0700 (PDT) X-Received: by 2002:a9d:2dc1:: with SMTP id g59mr4038568otb.288.1589582957441; Fri, 15 May 2020 15:49:17 -0700 (PDT) X-Original-Sender: vittorio.romeo.vee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:25207 Archived-At: ------=_Part_755_1520942239.1589582956800 Content-Type: multipart/alternative; boundary="----=_Part_756_2131764442.1589582956800" ------=_Part_756_2131764442.1589582956800 Content-Type: text/plain; charset="UTF-8" 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. ------=_Part_756_2131764442.1589582956800 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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) =3D=3D pf.CodeBlock:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return pf.Div(elem,= attributes=3D{'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) =3D=3D pf.CodeBlock:
=C2=A0 =C2=A0 elemSt= r =3D pf.stringify(elem)
=C2=A0 =C2=A0 lines =3D [pf.LineItem(pf.Str(x)) for x in elemStr.split= lines()]
=C2=A0 =C2= =A0 return pf.Div(pf.LineBlock(*lines),=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 attri= butes=3D{ 'custom-style': 'Source Code Boxed'})

The above works (it surrounds my code blo= ck in a box in my final `.docx` output), but all syntax highlighting is los= t.

**Is there a way to achieve my desired result?*= * I would the code being surrounded in a box (thanks to my `'Source Cod= e Boxed'` style), but still retain its syntax highlighting.

I ha= ve the same problem with TableCell, by the way.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.co= m.
------=_Part_756_2131764442.1589582956800-- ------=_Part_755_1520942239.1589582956800--