public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Alan <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Cc: Jesse Rosenthal <jrosenthal-4GNroTWusrE@public.gmane.org>
Subject: Re: docx writer: using styles from reference document
Date: Mon, 20 May 2019 15:40:14 +0200	[thread overview]
Message-ID: <CABQ_dt-uz_JTNFiHTfC1zBzUBeXnDbTL457OeZ_gUozVQc5p0Q@mail.gmail.com> (raw)
In-Reply-To: <CAKAWQkXpaypSpUU62p=Fr_bhyLhLuAKMQ18MOy2TzTu6LmV3jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 6625 bytes --]

Hi Brandon

Jesse shared this with me earlier in the thread, it helped a lot:
https://pandoc.org/lua-filters.html

cheers
Alan

On Mon, May 20, 2019 at 3:09 PM Brandon Keith Biggs <
brandonkeithbiggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Hello,
> I would love a link in the documentation to a guide on using these
> filters, because having a TOC, title page, controlling page numbers, and
> all that is very common when using word.
> Thanks,
>
> Brandon Keith Biggs <http://brandonkeithbiggs.com/>
>
>
> On Mon, May 20, 2019 at 6:06 AM Alan <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> 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 <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <alan.mcl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <jrosenthal-4GNroTWusrE@public.gmane.org>
>>>> 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="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
>> <https://groups.google.com/d/msgid/pandoc-discuss/CABQ_dt_VkYEL5ED8i8Wo7GUeNA-Kgwyzjpzw2V%3DvdWYt1%2BkCLg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pandoc-discuss/zzEvOYD3IR4/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAKAWQkXpaypSpUU62p%3DFr_bhyLhLuAKMQ18MOy2TzTu6LmV3jg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pandoc-discuss/CAKAWQkXpaypSpUU62p%3DFr_bhyLhLuAKMQ18MOy2TzTu6LmV3jg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-uz_JTNFiHTfC1zBzUBeXnDbTL457OeZ_gUozVQc5p0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 10241 bytes --]

  parent reply	other threads:[~2019-05-20 13:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 15:15 Alan McLachlan
     [not found] ` <0c37bc1d-ea10-4945-98a8-b169997ac437-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-06 15:36   ` Jesse Rosenthal
     [not found]     ` <87v9ynr3wc.fsf-4GNroTWusrE@public.gmane.org>
2019-05-06 15:41       ` Alan
     [not found]         ` <CABQ_dt8PD7jtvWt-8w92nLqK-hiusUVxR=P-JfnYEJembQ2XPQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-10 14:29           ` Alan
     [not found]             ` <CABQ_dt9Ee-2dtNgPm7D_jJxhReAzk1Gg2tjVvn2Jah96jSif4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-20 13:06               ` Alan
     [not found]                 ` <CABQ_dt_VkYEL5ED8i8Wo7GUeNA-Kgwyzjpzw2V=vdWYt1+kCLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-20 13:09                   ` Brandon Keith Biggs
     [not found]                     ` <CAKAWQkXpaypSpUU62p=Fr_bhyLhLuAKMQ18MOy2TzTu6LmV3jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-20 13:40                       ` Alan [this message]
2019-05-20 16:40                   ` John MacFarlane
     [not found]                     ` <yh480ksgt95bb0.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-05-20 17:17                       ` Jesse Rosenthal
     [not found]                         ` <87y331f3jz.fsf-4GNroTWusrE@public.gmane.org>
2019-05-21 14:26                           ` Alan
     [not found]                             ` <CABQ_dt-d1KyE2U4_Hgfbx4=2tMtUaHO-5SfrnqJs8HLFEtTG4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-23 12:49                               ` Agustín Martín
     [not found]                                 ` <52a0ab63-6bb8-4d35-9736-c6a654fc5982-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-27  6:06                                   ` Alan
     [not found]                                     ` <CABQ_dt9jbn1avtHeq3cJpCe3fGbfAWTJFRdG5oukGPKxRcPr7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-16 18:55                                       ` Neil Piper

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=CABQ_dt-uz_JTNFiHTfC1zBzUBeXnDbTL457OeZ_gUozVQc5p0Q@mail.gmail.com \
    --to=alan.mcl-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=jrosenthal-4GNroTWusrE@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).