From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/22694 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Newsgroups: gmane.text.pandoc Subject: Re: docx writer: using styles from reference document Date: Fri, 10 May 2019 16:29:19 +0200 Message-ID: References: <0c37bc1d-ea10-4945-98a8-b169997ac437@googlegroups.com> <87v9ynr3wc.fsf@jhu.edu> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000000b14000588896512" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="151056"; mail-complaints-to="usenet@blaine.gmane.org" Cc: pandoc-discuss To: Jesse Rosenthal Original-X-From: pandoc-discuss+bncBCHJFA6CVYERBS4V23TAKGQEC47A7WY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri May 10 16:29:32 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wr1-f61.google.com ([209.85.221.61]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hP6Wi-000d8q-GZ for gtp-pandoc-discuss@m.gmane.org; Fri, 10 May 2019 16:29:32 +0200 Original-Received: by mail-wr1-f61.google.com with SMTP id r16sf2071132wrj.13 for ; Fri, 10 May 2019 07:29:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1557498572; cv=pass; d=google.com; s=arc-20160816; b=p3L7MocFBdvIJo382uwTQbf+sxf9vX66xjW5YlxFbhGkEBNoslHAb/otcWXcz0JN+F 7CVMkMfoYxitZ6y361ztV0DrKq0U37Pp37yBPE5J9ZHYqOf1vOvhPvYxIHDCW78YBYFS juq1PhHKEQJOtwYXvd169v1u1rIcEF5C/Rf/K/fKkZk8dgndrd8mFxWd9G5ARCC/zVmS UYaksDWXwX1uG0w+04bcxxTi/zGLfRiwqrVzvpidL+2Cy9ovlNMWeM3tM2ITVkeSF5u2 vE8Pet4t72OVK6Pe7OBI4eOgfrQYpS8Wt43F2mZtsRYzZ2/riE9RyQCxImlKXo3n+WrN 5+Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=Hl/GsrfVTQQxv2PjDJmeqhIze7Lcgz/ElsX3I7T+qYs=; b=mpT03B8TH1ootG4Kzkm32BSfR2OYfz+h7iPr5NdU90GFFeOVxH6nBQufX3iQCAr/Rw JfqwYH+Vkh/OmVo/4k6pU+ZL57Ua69UnYu9Dm7aDfCzlh+gP3+InDYLNI7qpopMbustp ssO5PWNJH5JbQaVsylWmqfJLIb9Yh/EQma0uB6s+LXUob46BTk398htgbOu4OjDbcM/7 Ep1MvLhXNc2PwBhcoiHdZKe9CSnVtMF9prjhjyRvZYozQi3sPuKx5AK/cn/K4AB3qkZi D0hjuSXU0t3Nof+U0B/wkSpCf7v/FVIhr3btrnlHwTyeMrDhU26RNydXXfovNLuPJ+wb gfFg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G7P2KV3e; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:cc:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=Hl/GsrfVTQQxv2PjDJmeqhIze7Lcgz/ElsX3I7T+qYs=; b=P37fpl0Esssx9/pfY2zbZ9v4SgGm/t1A3fYXSSX221gVuoosrKsGur9GgOb1qUFLAH TQsXss6wnFWvi9LcLu4EL13C8aiDlHhkW7ibKdzKh05/CS30cLVACjmx1EpuQQWn5Khf s/2t0U6DQem2BGtBsVz7WyibuToOqbZAWiJhuzZ39VRpgmjWGEVJZUmboKO/KILB4knL JDap807cGOB4sRXqrXuOZCZpLehz2Y3RT4qzEmyfjT3NkcIAYVweuD9OFL05YGinjSGa TXbri68H+g9gKDqlM+RPQXh3Z8gE3nZVu4XURBHvOxYYZW8V+bzwSar5MwYEHO7v+gQJ EVMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Hl/GsrfVTQQxv2PjDJmeqhIze7Lcgz/ElsX3I7T+qYs=; b=CiAl/R/PQE+awVrZT6HPW0abZYHnXNbhwAD2DteG/d8MromHx9lcUGiSHInLylAoKD Oz6OHkjrLeK+Ke93UTWQalPyWUotZEpCdfSLxsyjoWQv8pconFFq+f9dQ5Vw19P4O7Rz 1Mlo1qCQmfvg/18QMmlNpYo66Oz9NCvpAPobR9Yb5edz5IKfObh+TgnSAb+0NLAgAt4b NqZI7LBgd7n3qDn0YKTNXzyZ4acwfRHbu252c4ShdZWIIp5Tr6uJq9xqsM+PLcHx+SAL 1FHyZaL9wBoMrAuDofNtAJ2pCf/2z1GqxmNkq2VZuGlkginHLDr/hYKdo6vs2ZbORMMC 23ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:cc:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Hl/GsrfVTQQxv2PjDJmeqhIze7Lcgz/ElsX3I7T+qYs=; b=dClC8Xdj24Ar+XWEJ8W6TLwXaVAFeTs+arG9nc/om9w1xbzNE+rKkovg5zW0byNJxk 4m3jbZSIbmQUAwcaABsXxlUgkqCehrt3AF27KC4f1Tu0tpxaTdQchJlRe1w/SF0Rvpe5 S99XYEaiYxUtLSjFY7FFx3FZBt+OgzmF4GU+fxEsuQS3dz7kPl5dtMoRRH85NIctRFKE JrT67cGGrld5wqbaOoh54NWzdauOta8Fpt23wDomavBisoPu7Ca+WK/oA3ZtXMNpde51 0a5IOIdDKMyQtldo08PDtTKT+Ric4beNMbqK3qYWMD50rh4tgBI7NJQM0A2AJq6ABq+K c9NQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAVmwhFOh7V0+gqV6y20e+eKU1zxj+LA/IFlJdIFrKHODmM0rkN6 SYY5kWmjmqK4WQe1Q0W2rsY= X-Google-Smtp-Source: APXvYqzlsp7LyZ287vQBHrQoSbFMYW+r3v2cnmxXKNiTaSfIltUw6GYc43ia1UWHcwwpEm0tETyZfw== X-Received: by 2002:adf:b456:: with SMTP id v22mr6153105wrd.55.1557498572052; Fri, 10 May 2019 07:29:32 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a5d:5287:: with SMTP id c7ls1452856wrv.6.gmail; Fri, 10 May 2019 07:29:31 -0700 (PDT) X-Received: by 2002:adf:9e86:: with SMTP id a6mr8629340wrf.178.1557498570959; Fri, 10 May 2019 07:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557498570; cv=none; d=google.com; s=arc-20160816; b=stXR/W5V9ExmwbJiUtJeKQ2kOzsEHs56W89ih+0XCQRRVvDvr/T+VdItd4lvuliX/w mPcEuKffVfb8NuhtFux0RfODcDwU5RRny7DW72WTmb5x9j7xby4Oyl9qDbfj5PU8XiXv EHa03N4oiQ0yj9JZXxDE1leXTV2T+xRKEbZQz3ZVn0PXf4B9TNwO7evW4E3BlV6v9JgK oIjU8NUcs588jkG4e53oqX+l4EOGhszcV0cXVP/C3/xgFUuUVq4e8mKLwL7Jx9kFUlhy DKR7asoSAK6KZaOmlZFrfSGsXs/beHaQ5KK3z5hGqLYEV3M89re/ZGVXXqznmy3r67rv MBUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=ExwtTAK0DvB1CtLiO7cAu5nSoPiAbVP2Sj9W5BJqw7U=; b=jL91Tg/a5eKGlW4hBYpYrHRlBNiLy2XPpGWKyPyTHHQH0hBJgYid+P8gBnP4NAxMs/ N2oa5B939L2M+okm7sG5BR6OsJchBBo1M4zvjbxZ2S3THgYGSXRRBqzNz8CgSz92CEu8 7rey1sAlyhOY6j+KEFzZ5vIJi6tA9ZPGMLK8JKoBooyfGFYM7hx6Sj510PtYj6f8GLt2 Z4bJT4IleZEyqseWQwDJUMXgRD+r6LGRkZ/TeKjLuXadffwuDS8FjFhSGGpd2RhA/sXx 3ZxDDj/N466rvO/+V42IyThZTTUU+X9KkmihNMy9B3QEl30eP84Gxa2SL/CjtOu7i8Zy UZPQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G7P2KV3e; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com. [2a00:1450:4864:20::430]) by gmr-mx.google.com with ESMTPS id 61si973422wra.0.2019.05.10.07.29.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 07:29:30 -0700 (PDT) Received-SPF: pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::430 as permitted sender) client-ip=2a00:1450:4864:20::430; Original-Received: by mail-wr1-x430.google.com with SMTP id s15so8130996wra.12 for ; Fri, 10 May 2019 07:29:30 -0700 (PDT) X-Received: by 2002:adf:b243:: with SMTP id y3mr7823178wra.21.1557498570673; Fri, 10 May 2019 07:29:30 -0700 (PDT) In-Reply-To: X-Original-Sender: alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G7P2KV3e; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::430 as permitted sender) smtp.mailfrom=alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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.org gmane.text.pandoc:22694 Archived-At: --0000000000000b14000588896512 Content-Type: text/plain; charset="UTF-8" Hi The lua filter approach is working reasonably well but I have a couple more in depth questions. For context, my pandoc input format is docbook generated from asciidoc. 1. Title, subtitle, author and other meta elements: how do I apply styles to them? - I've tried wrapping them in Spans (inside a "function Pandoc(doc)") as suggested by the custom-style docs, but they don't pick up any styles. - I tried turning them into Div/Para objects in the main body, but then they appear after the generated TOC. Basically I need to support setting up a cover page followed by a TOC. 2. Page breaks/hard breaks. They don't seem to be supported by the Pandoc internal model. Any suggestions for getting around this? Also related to the cover page need. regards Alan On Mon, May 6, 2019 at 5:41 PM Alan wrote: > Thanks for the reply Jesse > > I did check out the custom styles, but you are right that I'd rather not > embed that in every paragraph. I'm dealing with moderately large documents > and it would get old pretty fast. > > I hadn't considered the lua filters yet. Good idea, I will give it a try. > > regards > Alan > > On Mon, May 6, 2019 at 5:36 PM Jesse Rosenthal wrote: > >> Alan McLachlan writes: >> >> > pandoc today generates the paragraph text set to "Normal" >> > style, I want it to use "My Style 1" instead of Normal. >> >> This is a job for custom-styles: >> https://pandoc.org/MANUAL.html#custom-styles >> >> So, one (not particularly user-friendly) way to do it would be to wrap >> ever paragaph in a div, to give it a custom style >> >> ~~~ >> ::: {custom-style="My Style 1"} >> Here is a paragraph. >> ::: >> >> ::: {custom-style="My Style 1"} >> Here is another. >> ::: >> ~~~ >> >> But you probably don't want to do that -- instead, it would be nice to >> just write as normal: >> >> ~~~ >> Here is a paragraph. >> >> Here is another. >> ~~~ >> >> and then have paragraphs converted on the fly. To do that, you'd use a >> pandoc filter (https://pandoc.org/lua-filters.html): >> >> ~~~ >> function Para(blk) >> local attr = pandoc.Attr() >> attr.attributes["custom-style"] = "My Style 1" >> return pandoc.Div({blk}, attr) >> end >> ~~~ >> >> That will convert all plain paras into a styled div. Save that in a file >> (`style.lua`), and then run it on the simple markdown file: >> >> `pandoc input.md --lua-filter=styler.lua -o output.docx` >> >> >> -- 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/CABQ_dt9Ee-2dtNgPm7D_jJxhReAzk1Gg2tjVvn2Jah96jSif4Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. --0000000000000b14000588896512 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

The lua filter approach i= s working reasonably well but I have a couple more in depth questions. For = context, my pandoc input format is docbook generated from asciidoc.

1. Title, subtitle, author and other meta elements: h= ow do I apply styles to them?
=C2=A0- I've tried wrappin= g them in Spans (inside a "function Pandoc(doc)") as suggested by= the custom-style docs, but they don't pick up any styles.
=C2=A0- I tried turning them into Div/Para objects in the main body, but= then they appear after the generated TOC.
Basically I need to su= pport setting up a cover page followed by a TOC.

2. Page breaks/hard breaks. They don't seem to be supported by the P= andoc internal model. Any suggestions for getting around this?
Al= so related to the cover page need.

regards
Alan


On Mon, May 6, 2019 at 5:41 PM Alan <= ;alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
<= div>Thanks for the reply Jesse

I did check out the= custom styles, but you are right that I'd rather not embed that in eve= ry paragraph. I'm dealing with moderately large documents and it would = get old pretty fast.

I hadn't considered the l= ua filters yet. Good idea, I will give it a try.

r= egards
Alan

On Mon, May 6, 2019 at 5:36 PM Jesse Rosenth= al <jrosenthal@j= hu.edu> wrote:
Alan McLachlan <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> pandoc today generates the paragraph text set to "Normal" > style, I want it to use "My Style 1" instead of Normal.

This is a job for custom-styles:
https://pandoc.org/MANUAL.html#custom-styles

So, one (not particularly user-friendly) way to do it would be to wrap
ever paragaph in a div, to give it a custom style

~~~
::: {custom-style=3D"My Style 1"}
Here is a paragraph.
:::

::: {custom-style=3D"My Style 1"}
Here is another.
:::
~~~

But you probably don't want to do that -- instead, it would be nice to<= br> just write as normal:

~~~
Here is a paragraph.

Here is another.
~~~

and then have paragraphs converted on the fly. To do that, you'd use a<= br> pandoc filter (https://pandoc.org/lua-filters.html):

~~~
function Para(blk)
=C2=A0 =C2=A0local attr =3D pandoc.Attr()
=C2=A0 =C2=A0attr.attributes["custom-style"] =3D "My Style 1= "
=C2=A0 =C2=A0return pandoc.Div({blk}, attr)
end
~~~

That will convert all plain paras into a styled div. Save that in a file (`style.lua`), and then run it on the simple markdown file:

`pandoc input.md --lua-filter=3Dstyler.lua -o output.docx`


--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/CABQ_dt9Ee-2dtNgPm7D_jJxhReAzk1Gg2tjVvn2J= ah96jSif4Q%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--0000000000000b14000588896512--