From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/22679 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, 6 May 2019 17:41:35 +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="00000000000021beaf058839f031" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="59764"; mail-complaints-to="usenet@blaine.gmane.org" Cc: pandoc-discuss To: Jesse Rosenthal Original-X-From: pandoc-discuss+bncBCHJFA6CVYERBO5LYHTAKGQESJNIN7I-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon May 06 17:41:48 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ed1-f60.google.com ([209.85.208.60]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hNfkS-000FRR-Dv for gtp-pandoc-discuss@m.gmane.org; Mon, 06 May 2019 17:41:48 +0200 Original-Received: by mail-ed1-f60.google.com with SMTP id c26sf12497762eda.15 for ; Mon, 06 May 2019 08:41:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1557157308; cv=pass; d=google.com; s=arc-20160816; b=DbPeoGsRVNcbSV88Zd4GmUQi8xYBML7metS+bZNfasUj7oGcNhj2cqPg6oppNjswfu Su3wJ3lCvDco381BvMjzLsDtiPkZD9PxrM5F/O7yzEyOLPBsVXwefzgd3E/AZhiNuobV PSye0j4kR/sCmid7tNqq9PGbLh1UvAt6U7lD52t6HRB+EBb2Bfw9q4DeNla2h3W1EljH 2KKCX0zJH6wiIML9tCA9WkP6nBPxwz5iyMsqYtQzZ1c5B22jBGWSvOzuO63VtS5nd00s INaTx2iUU6S2sxoBEOfkz3yuZx/cppft+SyOlZZGNMOe/WIN0y0UZQb2CI3ku2NPkQse 8TMQ== 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=I7GwvlrUa4TvouAvCi0pANeVhbkoIlaMl9B+WnPLGyw=; b=ennfHlCCF9HkO2XwFiKyn8dPmtu7aZk70lORUx0Yk4uCUR8IJuX3mhpEa4baq241NI tO4Ff2peBWWuWpm+2XRs0nps8vFNktcI0teIlsCwbP0r+kevTttEJwhK7nW9zApXiriu VA/IstxxvXaXZ20iYyrMnSIVg1gyC6q8VS7w1/pN51VXqKfreKTrAPavWCXm6+orDq0p PJn8oD+uMO3Isx6wZUL6xil3bS7HBjPLdDoJVYmmTPv8TfJRuqfEnJh4leADeW+MeupL uY57htGm0skUbbYi77GUyui11o173uLwh4Iokxak3Ou0f5bKdics5Ep8NyagzrSGBdRp WezQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tT8arJ29; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32e 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=I7GwvlrUa4TvouAvCi0pANeVhbkoIlaMl9B+WnPLGyw=; b=c+rH/8WD/Rr0e97D+Rp0xgf4/m2gtI3a26pG0L+FHtTgvsBKKJ4HT09XgU4k8yg4Ba jjlyih0kkHyVeH/z6hXqc2y/BK7c4L39qbjdl//jK/1ySyWOePRPI2SiKHqEi1h6hvXM iieSqg09RiKZnFEBjbzHYdvSZlk9dRwVLizHsvmhiQ6eJXTO8GUuoR4GSQLmFyyXCnx/ INJWtOtcP3vIJwXkkTZeevMGMdZDkjkadKV15/g4V/D7mogWZwKSgYClOS7N7+ODmwRI RKA/MWSPA2EneMdktUDmDliI2hTPwkB4xlYzgCJQ2H2Phu0Or06QwCpLh3NQwGXpR1jv B20Q== 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=I7GwvlrUa4TvouAvCi0pANeVhbkoIlaMl9B+WnPLGyw=; b=o8OWraPz2E5aecp80Mzqf7ZAv3UHaBtdcS2RSmON5IRSLaC6d1yJEBU3LWc7KRgKON BKv5Kcqj0mIQI97tdw3yB5gujEmhydSxHQdw0FHtE4ImrT06lSVYOAJbY2AdHL51wmjE /39wnhoYBHKFdQZ8M4hsp1BEq6eEpKQltT2qIa9LLnpqSkCUM57JeaqfPBJfbb/76slv J5UZG+zNgJ8va9Hd7Sz1JJ1M31fihwEV1Y3IkUDyitRhvvnmL5fhHtaM53cfUJjEGoTh jxxcajzZRWNZGNm1yz0W7QHcjOP57APi0G7CsX+u6Zm2eMKk4vO5myCmP5Y0CcnfqoA2 FxHQ== 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=I7GwvlrUa4TvouAvCi0pANeVhbkoIlaMl9B+WnPLGyw=; b=JSmm5QcJfpVQT1Ye+eTKUjjlDOFHE/+n1WkKyQhvJxWXy8IZkIL4su4uC+BJrqXhUK Ix8Rv1JtXi1GOwwcEi0osk4O0fdFX9TsImtIbzYo1QVGdyf1DCOpRppdTdqvESIlj/Xq RxBfCJRQNFNJBj2ZJ6yytjeExqBik9pjBULLpDMsx6JTYjATF+97HDLT6oZzlNuD2M4V U8tDysb6Lb78nhrd3Rl+c6IK4HoFo0JF4i3zfX7HKpELt4gevWiazmscDFkty+2uvYjg 8FxHcmrPRRo8oJJXY1C288+eu7BBfunmnjBqFahEXTd/ufp62cTlCZ3xuD06HOkuzgwD CIFQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAUCAdaTwrX1JpasvsaVAssJfAVd77jh9UALXb+v5ORSDwdguPmn WSzX8/YpjGYQHgj0XWhLByo= X-Google-Smtp-Source: APXvYqyqwDQ2lktSXWB8oL6BDRtkcf4Dh0QnqMgkKA+rd8VmZNhBs6JLDMuqc4QE7oeX12KQ/Qx3DQ== X-Received: by 2002:a17:906:9248:: with SMTP id c8mr19354814ejx.156.1557157307946; Mon, 06 May 2019 08:41:47 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a50:8c64:: with SMTP id p91ls1851565edp.7.gmail; Mon, 06 May 2019 08:41:47 -0700 (PDT) X-Received: by 2002:a50:be44:: with SMTP id b4mr20871534edi.35.1557157307099; Mon, 06 May 2019 08:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557157307; cv=none; d=google.com; s=arc-20160816; b=kS79Y3AEwkuRkp8kYdqubSIvtmELgKufKxhTK4BXT5jNzAHfuxuKG7bH6PaswxtCk0 jqpCnz3G+1Df8kQqfefgtpI+j/PvguXTFBUDk4mE3X4QoRsboyKCVweZlIebfNkydZIb 9in5R33f/BAvV2hSoTJASguhQtyRv23I1z3ihYsdm+aueultAPvePgaNf0w8bNhu/8hh oucX84Nvkx2pLvzUw6M/q12STP3UlfrJogNdISXOptnepuMTuwsUwjFqdVTazD/F7KT8 jxGknJit9mGyXboS2cBSXfFuEiGhOmDLfyHPDqQW7SKfblvxOt5gv4bQsWFnP8xrx4fs IuXQ== 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=N2PDof46H2MZKw/dhd7uMlqbNmeK7UTIZI6ddC6kSR8=; b=rc0sdAzSWUpsR/ti7Sj0EBwwKzKy7ChjdsH4hcf7z11WeVBILkBFoLsLAr5iYsHozW qDyCAcYfYQgUKuW16GkW5V4uPgVNeWa3CJm8kdJvOSY2wYeT9mv0caIE88Q9uZnX0/qQ 6IriLOme7PD/BuLcRTieLIPF6g6VcuxV4Pr2uHacPaLSKKn2GWShWj9XyKRNqu1H0x5l E0J42wmei0UrtrHhl/3qNz/nUn115QQMWQgCHPE7yOqaoRvCC4/xWVxoT907IgXNfVz+ fsxW0ugYmN8CQZz65gsDxlStzgmQuQhJgR5v82oPPUwhursc6Q+eqkMalHi4TsignJg7 c9tA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tT8arJ29; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32e 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-x32e.google.com (mail-wm1-x32e.google.com. [2a00:1450:4864:20::32e]) by gmr-mx.google.com with ESMTPS id l30si595691edd.4.2019.05.06.08.41.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 08:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32e as permitted sender) client-ip=2a00:1450:4864:20::32e; Original-Received: by mail-wm1-x32e.google.com with SMTP id o189so5425275wmb.1 for ; Mon, 06 May 2019 08:41:47 -0700 (PDT) X-Received: by 2002:a05:600c:24f:: with SMTP id 15mr16383243wmj.48.1557157306808; Mon, 06 May 2019 08:41:46 -0700 (PDT) In-Reply-To: <87v9ynr3wc.fsf-4GNroTWusrE@public.gmane.org> 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=tT8arJ29; spf=pass (google.com: domain of alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::32e 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:22679 Archived-At: --00000000000021beaf058839f031 Content-Type: text/plain; charset="UTF-8" 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_dt8PD7jtvWt-8w92nLqK-hiusUVxR%3DP-JfnYEJembQ2XPQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. --00000000000021beaf058839f031 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 docum= ents 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:3= 6 PM Jesse Rosenthal <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://group= s.google.com/d/msgid/pandoc-discuss/CABQ_dt8PD7jtvWt-8w92nLqK-hiusUVxR%3DP-= JfnYEJembQ2XPQ%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--00000000000021beaf058839f031--