From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/22763 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: Mon, 20 May 2019 15:06:26 +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="00000000000010923d05895167d7" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="21196"; mail-complaints-to="usenet@blaine.gmane.org" Cc: pandoc-discuss To: Jesse Rosenthal Original-X-From: pandoc-discuss+bncBCHJFA6CVYERBX6MRLTQKGQEXYX72AQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon May 20 15:06:41 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-lf1-f60.google.com ([209.85.167.60]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hSi00-0005MI-C2 for gtp-pandoc-discuss@m.gmane.org; Mon, 20 May 2019 15:06:40 +0200 Original-Received: by mail-lf1-f60.google.com with SMTP id 134sf2594657lfk.23 for ; Mon, 20 May 2019 06:06:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1558357599; cv=pass; d=google.com; s=arc-20160816; b=Zy1ilolZzWsuL/okCJxVLm8egKECnkWEpgQjYCouQzOxJuWVEhz3HgSiqi5StmFzue o5dFMhYGMxOkKBLKq27yTP5kjDVOIZdLCPAnkJV3WUa6pCoAEbQ+dmbd9irGpXaNXNJm 9E7eTqJrod+dlKReJPh/db2L49uZbjYqn+NHI5fQXDXb+Y157axeQXUYbjgITOavWgr6 z1E959XV0WNWTW8wavEdtrwvfaj6l6Dl8/1hDDHN4No913q+HPwLJLPWbUzKLvDjMoXg FqMtnQGm2I9OYmkpj9pvZtPdguzuIKjLoFLq/UztQ0JGo8UW/jC5qh1H7JEZGM1axZ1M AQ6w== 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=TYqtsy4uW5mfyKXKAwhf4lGFmS1perTxY/weq/4M8BU=; b=O9sLuNXcvcZh9doYznSVVAWpLU3GZYAJwWS+q+1S02uQB6vOMvFbbQTEZ9NxEvfacP RKYcwMtom364c8wt2pUxuPeCGulFmTe+c1u+yDFOsv6565ok1SIIJCP/VbOkWvLMOrpc XzkOUHUz+ZEKl7oRr0XQo9pNiKVOsA16rLu+68cxJ/DIK2jj2btNV6agxzUuaYIfIDb5 hw57uEiwxl1N/ytRrbAlVfk5MRCjR5J9iZddAvWhtW0meeCqnsW4Q3ZU5Bno6lafktuq oqvXrYEzEyAWtqZP1g4v78YKrxDsUNjT8DqhDNIWdiL0u6qCrgEeQymFDYC5+e4S9zAT 9mZA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF3aXDNF; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::336 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=TYqtsy4uW5mfyKXKAwhf4lGFmS1perTxY/weq/4M8BU=; b=K37dDroVrlMHGkqckur4BjlKPgcBbp/unHicScjhj7k7Bt3SgUnzlecHRMUoQrXbp7 lBCVeqHg7L/6YMF5s9glbgioRegoOWtN3wBTNNM0Iiu0IyWBcbO2NnfIt3AfYm9q6kwy DCQwWvuQ+OzwoDCgbf0LYdhFWbqQhW4J0+x4ItZ2oaEs3VdFU0nUhk9b+N6VI5I+CPUe +R9zkhIaE4ryA9A1fqgjGCDqTG/+ybOmxmUSWfy1S6Oc7v3NRGWedoIMKr6LJQI3hqv2 WtsV9pUqmiNKKgLVDrMEEy0UYAUJJRArx5Orzpf3DLZUnINY9njXkH1tYQD+DMHP7MfP +1Ew== 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=TYqtsy4uW5mfyKXKAwhf4lGFmS1perTxY/weq/4M8BU=; b=RyFFuSFF16mhmTgU+9EY0331m7H2x8PSAh/3mYxsZ1gKbWp0oPX8EE0666lfZ1CU2w MpNaUckG6xZWECJWqsGRK2TuPtKnHfv+yp3h8QTgixaShs4YKB6y020DTslEpfVNF8d0 vsX4V2GWqxl6x2+ULy038EyJRUpR1NQ1qoEIXvTmv+epKohobzxkZ2c/hMxSuJIVu/yB ZPMdFXfMfHq9NtD0srrfd0HTkcnQJ6Wtt4dWSdTdQvQSuX8iaCb20NpRKDLCNODXY3B6 xSoI1529Tbt7nxs3hBE6Ljv//ep2GuFF5T5ZRF1d2E+QGd/t8+1fCaUSxIAO2L2f50N/ CDKQ== 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=TYqtsy4uW5mfyKXKAwhf4lGFmS1perTxY/weq/4M8BU=; b=mTjtcGyI10rehRkzCy13KvB/9k0gxZII7TNtAtSzotRMygdpJMzQVNo1FF13493H2s TQlA1X1L48espLieRXXPlzy7lT/8koFMsQdaU3u1/GPP8MoCFH/TC/pXhFdqhCP6D6tf /MPMw9HlovV5t3HhRWxaxV4ts9ocQBtTZ6OM2hgJYn09KObVRPmHezxRc9JXOWjW7LXD u079jbLnDhGzAsM6qA+jERYjMyLiuY2xc+6LR0uxoqVFQ3y/eFCk1A4fLgb03/k+GsmA mYPOmEPF2eWVNmYdBYbydJT3HobdWN0Ico0fKbaTPszQZlpefB9RTAJYJuGjn59eQnxF w5sg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAXyagpidc2t0bgxOsxtw7p7XIl0FpVPRIFvsGmxiscwnIngCjSq +kFT11Vx3HoT9ygVsQ01HMw= X-Google-Smtp-Source: APXvYqzQX9IXBeI0kDsG46l3Mvcik51Va9rb8sbj8K3MLvdUsd9JBRGT1CvyZLJ8Zf8HYwGYJ5VnRA== X-Received: by 2002:a2e:12ce:: with SMTP id 75mr7451322ljs.7.1558357599731; Mon, 20 May 2019 06:06:39 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a2e:12cd:: with SMTP id 74ls486093ljs.4.gmail; Mon, 20 May 2019 06:06:38 -0700 (PDT) X-Received: by 2002:a2e:8185:: with SMTP id e5mr5502882ljg.14.1558357598424; Mon, 20 May 2019 06:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558357598; cv=none; d=google.com; s=arc-20160816; b=K4xlWcbtPWpeqkMd53Sx656BiOcFn7bOxiJ55frWlUX+HRSGgGq8WxR/1Fh34lKtYs 6bdmP4FOOX6ll8w03K8OiAMegiSSGNpvtV175SK88Xou91bktnoW8V/i7gb2NgvnOOtj gwlIsUm2Joclk10BMC8ML009OHnIEL6RxVVo9+6WCMqvGmB/yHp4NzeJhPSmdMW4MF/s dei0IEgMDmRlAzvywerDaCdQQRAPzWzfFoiocpdik4o2RX1gJVlQSLDAdlMENftSacKE 5sUDS9//1cFisfQ3QaztzmZiInoppGFkl8X6MCO3wsGnMefm/0jBhCgrXEvQDjwigF00 zLyw== 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=wrhovbOfKNlnShVmpF+AbSoaQGcWYwfSxiTfDo7SpaU=; b=b5ql11+Z7f3srLdEDcVAT5OetZEIq9XEH30Hu7T7CXP1gZDxJh9enkAMGJ2YZUAFuD 84Z0K6JA+NTB2komk1hYo4LrIZsvEbZ6/7pkgNXMTfwdh0p06zYN52gW5qnNsCFBTgZK 7qWdfSNVCembF1jnc7QeCvQdq5h1vXe/BFczsU+mt1FYPCI0W+uOFye+Y5tMlpxxSCbw fMl7uDz+qQGI1ovDZaEiJoz+odg1cTYF+tK9aIZVSWrHjrB5KZXN136CTQfHBQXUhKGW g63VP6V9dxFPigX+yywTHj0T7FDc3xUfhjd0WB2zOgNRM+KyCtBmB1tVST6YL6XoaMJQ 7ebQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF3aXDNF; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::336 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-wm1-x336.google.com (mail-wm1-x336.google.com. [2a00:1450:4864:20::336]) by gmr-mx.google.com with ESMTPS id j7si1674805ljc.0.2019.05.20.06.06.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 06:06:38 -0700 (PDT) Received-SPF: pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::336 as permitted sender) client-ip=2a00:1450:4864:20::336; Original-Received: by mail-wm1-x336.google.com with SMTP id 15so8915954wmg.5 for ; Mon, 20 May 2019 06:06:38 -0700 (PDT) X-Received: by 2002:a1c:7511:: with SMTP id o17mr4617572wmc.39.1558357598047; Mon, 20 May 2019 06:06:38 -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=hF3aXDNF; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::336 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:22763 Archived-At: --00000000000010923d05895167d7 Content-Type: text/plain; charset="UTF-8" Hi I made some progress on this: 1. I got the cover page working by using the lua filter to remove all the meta data inlines then reconstructing it all as an "abstract" meta element. Handily the Abstract has Blocks not Inlines, so the custom styles work. And the TOC appears after the abstract. 2. Hard breaks remain a problem though. I can work around this on the cover page with some spacing, but that's not feasible for the rest of a typical document. Question: is the non-support hard breaks in Pandoc an intentional position, or is this just a gap that the community would be interested in filling if someone cared enough to implement it? One new challenge: 3. Page numbers. Can I use the lua filter to insert a page number footer in the generated docx? regards Alan On Fri, May 10, 2019 at 4:29 PM Alan wrote: > 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_dt_VkYEL5ED8i8Wo7GUeNA-Kgwyzjpzw2V%3DvdWYt1%2BkCLg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. --00000000000010923d05895167d7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

I made some progress on t= his:

1. I got the cover page working by using the = lua filter to remove all the meta data inlines then reconstructing it all a= s an "abstract" meta element. Handily the Abstract has Blocks not= Inlines, so the custom styles work. And the TOC appears after the abstract= .

2. Hard breaks remain a problem though. I ca= n work around this on the cover page with some spacing, but that's not = feasible for the rest of a typical document.
Question: is the non= -support hard breaks in Pandoc an intentional position, or is this just a g= ap that the community would be interested in filling if someone cared enoug= h to implement it?

One new challenge:
3. Page numbers. Can I use the lua filter to insert a page num= ber footer in the generated docx?

regards
Alan


On Fri, May 10, 2019 at 4:29 PM Alan <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
= Hi

The lua filter approach is working reasonably w= ell but I have a couple more in depth questions. For context, my pandoc inp= ut format is docbook generated from asciidoc.

= 1. Title, subtitle, author and other meta elements: how do I apply styles t= o them?
=C2=A0- I've tried wrapping them in Spans (insid= e a "function Pandoc(doc)") as suggested by the custom-style docs= , but they don't pick up any styles.
=C2=A0- I tried tur= ning them into Div/Para objects in the main body, but then they appear afte= r the generated TOC.
Basically I need to support setting up a cov= er 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 cove= r page need.

regards
Alan
<= div>

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 c= ustom 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 ge= t old pretty fast.

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

reg= ards
Alan

On Mon, May 6, 2019 at 5:36 PM Jesse Rosentha= l <jrosenthal@jh= u.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://gro= ups.google.com/d/msgid/pandoc-discuss/CABQ_dt_VkYEL5ED8i8Wo7GUeNA-Kgwyzjpzw= 2V%3DvdWYt1%2BkCLg%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--00000000000010923d05895167d7--