public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to specify number-offset?
@ 2020-09-27 17:07 'Karl Weber' via pandoc-discuss
       [not found] ` <200b15bc-f323-487e-b39d-e6be8845eacan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: 'Karl Weber' via pandoc-discuss @ 2020-09-27 17:07 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1175 bytes --]


Hi,

I do want to specify number-offset neither on the commandline of pandoc nor 
in the defaults yaml file. The reason is, that I have a project consisting 
of a number of documents in markdown format, that I want to convert to 
html5 using make. Hence I need to specify number-offset for each file 
individually. 

Is there some way to do this?

I tried to specify it in a yaml block at the beginning of each file, 
something like the following:

---
output: 
  html_document: 
    pandoc_args: [
      "--number-offset=4,0"
      ]
---

I tried different variations of this example, but none worked. Note, that 
my input format ist pandoc markdown.

It would be great, if something like that would work. I would appreciate 
any help.

Thanks in advance,
Karl


-- 
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/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2205 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found] ` <200b15bc-f323-487e-b39d-e6be8845eacan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-27 23:02   ` John MacFarlane
       [not found]     ` <m2v9fy258g.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2020-09-27 23:02 UTC (permalink / raw)
  To: 'Karl Weber' via pandoc-discuss, pandoc-discuss


No, you can't specify it in YAML metadata.

"'Karl Weber' via pandoc-discuss"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> Hi,
>
> I do want to specify number-offset neither on the commandline of pandoc nor 
> in the defaults yaml file. The reason is, that I have a project consisting 
> of a number of documents in markdown format, that I want to convert to 
> html5 using make. Hence I need to specify number-offset for each file 
> individually. 
>
> Is there some way to do this?
>
> I tried to specify it in a yaml block at the beginning of each file, 
> something like the following:
>
> ---
> output: 
>   html_document: 
>     pandoc_args: [
>       "--number-offset=4,0"
>       ]
> ---
>
> I tried different variations of this example, but none worked. Note, that 
> my input format ist pandoc markdown.
>
> It would be great, if something like that would work. I would appreciate 
> any help.
>
> Thanks in advance,
> Karl
>
>
> -- 
> 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/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]     ` <m2v9fy258g.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-09-28  6:08       ` 'Karl Weber' via pandoc-discuss
       [not found]         ` <1c0310ae-6348-4ba6-8d9d-746aab5e0c09n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: 'Karl Weber' via pandoc-discuss @ 2020-09-28  6:08 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3143 bytes --]

Hi John,

thank you for your answer. I would think it should be possible to do that 
with my own custom writer (in Lua). Is that right?

If so, how much work would it be? My starting point would be the sample.lua 
obtained though the command

pandoc --print-default-data-file sampla.lua

Is there an easier way to do this? How close is this sample.lua to what 
pandoc is doing for output format html5? I.e. how much would I have to add 
to sample.lua? Is it only my desired functionality or are there more 
differences? (I am using, for instance, --toc and --sections-div, which 
does not seem to be part of the sample.lua...) I did't find 
template-processing as well, but I am just starting to learn how to build 
my own custom writer... 

Im am using pandoc 2.10.1

This solution (if feasible) would have the advantage, that I could add more 
functionality I am currently missing (there may indeed be one or two 
things), but it would also have the disadvantage, that I would have to 
adapt my own custom writer, whenever pandoc evolves. However, this should 
only be necessary if the datamodel of pandoc is changing, or isn't it? I am 
still undecided.

Thanks in advance
Karl

John MacFarlane schrieb am Montag, 28. September 2020 um 01:02:41 UTC+2:

>
> No, you can't specify it in YAML metadata. 
>
> "'Karl Weber' via pandoc-discuss" 
> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes: 
>
> > Hi, 
> > 
> > I do want to specify number-offset neither on the commandline of pandoc 
> nor 
> > in the defaults yaml file. The reason is, that I have a project 
> consisting 
> > of a number of documents in markdown format, that I want to convert to 
> > html5 using make. Hence I need to specify number-offset for each file 
> > individually. 
> > 
> > Is there some way to do this? 
> > 
> > I tried to specify it in a yaml block at the beginning of each file, 
> > something like the following: 
> > 
> > --- 
> > output: 
> > html_document: 
> > pandoc_args: [ 
> > "--number-offset=4,0" 
> > ] 
> > --- 
> > 
> > I tried different variations of this example, but none worked. Note, 
> that 
> > my input format ist pandoc markdown. 
> > 
> > It would be great, if something like that would work. I would appreciate 
> > any help. 
> > 
> > Thanks in advance, 
> > Karl 
> > 
> > 
> > -- 
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com. 
>
>

-- 
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/1c0310ae-6348-4ba6-8d9d-746aab5e0c09n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4511 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]         ` <1c0310ae-6348-4ba6-8d9d-746aab5e0c09n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-28 18:32           ` 'Karl Weber' via pandoc-discuss
       [not found]             ` <90ec5cf3-3f74-4ae2-94a9-66d60d007ee1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-09-28 19:02           ` John MacFarlane
  1 sibling, 1 reply; 8+ messages in thread
From: 'Karl Weber' via pandoc-discuss @ 2020-09-28 18:32 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 4919 bytes --]

OK, I played around a little bit with sample.lua and have the following 
understanding:

(1) pandoc handles normal template usage in combination with sample.lua, I 
only have to set --template=... on the commandline. Everything is fine.

(2) Despite specifying --toc on the commandline, _no_ table of contents is 
produced with sample.lua! It seems, that pandoc internally sets the content 
for the table of contents to the metadata variable toc. In fact, if I add 
some arbitrary text to the metadata variable toc, e.g. in a yaml block, 
then a table of contents is printed with this text through my template. It 
does not matter, if --toc is used or not.

Question: How can I set the metadata variable toc in sample.lua? (I guess, 
I would have to create the toc myself in sample.lua). I tied to modify 
metadata in function Doc, but it didn't work.

(3) Section numbering does not work with sample.lua. How can I get the 
commandline arguments --number-sections and --number-offset=N in 
sample.lua? I guess, I would also have to do the section numbering myself 
in sample.lua.

(4) --sections-divs does not work in sample.lua. If I could read the 
commandline argument --section-divs in sample.lua, I could write the 
opening <section> tag in function Header. BUT: where and how could I create 
the closing </section> tag? Maybe I would have to put a closing tag right 
before the next opening tag in every call to function Header at the same or 
lower level and add the last closing tag in function Doc to the body. Or is 
there a better way? 

Thanks in advance for every help!
Regards
Karl
Karl Weber schrieb am Montag, 28. September 2020 um 08:08:11 UTC+2:

> Hi John,
>
> thank you for your answer. I would think it should be possible to do that 
> with my own custom writer (in Lua). Is that right?
>
> If so, how much work would it be? My starting point would be the 
> sample.lua obtained though the command
>
> pandoc --print-default-data-file sampla.lua
>
> Is there an easier way to do this? How close is this sample.lua to what 
> pandoc is doing for output format html5? I.e. how much would I have to add 
> to sample.lua? Is it only my desired functionality or are there more 
> differences? (I am using, for instance, --toc and --sections-div, which 
> does not seem to be part of the sample.lua...) I did't find 
> template-processing as well, but I am just starting to learn how to build 
> my own custom writer... 
>
> Im am using pandoc 2.10.1
>
> This solution (if feasible) would have the advantage, that I could add 
> more functionality I am currently missing (there may indeed be one or two 
> things), but it would also have the disadvantage, that I would have to 
> adapt my own custom writer, whenever pandoc evolves. However, this should 
> only be necessary if the datamodel of pandoc is changing, or isn't it? I am 
> still undecided.
>
> Thanks in advance
> Karl
>
> John MacFarlane schrieb am Montag, 28. September 2020 um 01:02:41 UTC+2:
>
>>
>> No, you can't specify it in YAML metadata. 
>>
>> "'Karl Weber' via pandoc-discuss" 
>> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes: 
>>
>> > Hi, 
>> > 
>> > I do want to specify number-offset neither on the commandline of pandoc 
>> nor 
>> > in the defaults yaml file. The reason is, that I have a project 
>> consisting 
>> > of a number of documents in markdown format, that I want to convert to 
>> > html5 using make. Hence I need to specify number-offset for each file 
>> > individually. 
>> > 
>> > Is there some way to do this? 
>> > 
>> > I tried to specify it in a yaml block at the beginning of each file, 
>> > something like the following: 
>> > 
>> > --- 
>> > output: 
>> > html_document: 
>> > pandoc_args: [ 
>> > "--number-offset=4,0" 
>> > ] 
>> > --- 
>> > 
>> > I tried different variations of this example, but none worked. Note, 
>> that 
>> > my input format ist pandoc markdown. 
>> > 
>> > It would be great, if something like that would work. I would 
>> appreciate 
>> > any help. 
>> > 
>> > Thanks in advance, 
>> > Karl 
>> > 
>> > 
>> > -- 
>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com. 
>>
>>
>

-- 
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/90ec5cf3-3f74-4ae2-94a9-66d60d007ee1n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 6583 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]         ` <1c0310ae-6348-4ba6-8d9d-746aab5e0c09n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-09-28 18:32           ` 'Karl Weber' via pandoc-discuss
@ 2020-09-28 19:02           ` John MacFarlane
       [not found]             ` <m2pn65208q.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2020-09-28 19:02 UTC (permalink / raw)
  To: 'Karl Weber' via pandoc-discuss, pandoc-discuss


I wouldn't use a custom writer for this.

An easier approach would be to use a wrapper shell script.
The script would peek into the markdown file, find the
setting for --number-offset, and call pandoc with the
same arguments as the shell script PLUS the relevant
--number-offset.


"'Karl Weber' via pandoc-discuss"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> Hi John,
>
> thank you for your answer. I would think it should be possible to do that 
> with my own custom writer (in Lua). Is that right?
>
> If so, how much work would it be? My starting point would be the sample.lua 
> obtained though the command
>
> pandoc --print-default-data-file sampla.lua
>
> Is there an easier way to do this? How close is this sample.lua to what 
> pandoc is doing for output format html5? I.e. how much would I have to add 
> to sample.lua? Is it only my desired functionality or are there more 
> differences? (I am using, for instance, --toc and --sections-div, which 
> does not seem to be part of the sample.lua...) I did't find 
> template-processing as well, but I am just starting to learn how to build 
> my own custom writer... 
>
> Im am using pandoc 2.10.1
>
> This solution (if feasible) would have the advantage, that I could add more 
> functionality I am currently missing (there may indeed be one or two 
> things), but it would also have the disadvantage, that I would have to 
> adapt my own custom writer, whenever pandoc evolves. However, this should 
> only be necessary if the datamodel of pandoc is changing, or isn't it? I am 
> still undecided.
>
> Thanks in advance
> Karl
>
> John MacFarlane schrieb am Montag, 28. September 2020 um 01:02:41 UTC+2:
>
>>
>> No, you can't specify it in YAML metadata. 
>>
>> "'Karl Weber' via pandoc-discuss" 
>> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes: 
>>
>> > Hi, 
>> > 
>> > I do want to specify number-offset neither on the commandline of pandoc 
>> nor 
>> > in the defaults yaml file. The reason is, that I have a project 
>> consisting 
>> > of a number of documents in markdown format, that I want to convert to 
>> > html5 using make. Hence I need to specify number-offset for each file 
>> > individually. 
>> > 
>> > Is there some way to do this? 
>> > 
>> > I tried to specify it in a yaml block at the beginning of each file, 
>> > something like the following: 
>> > 
>> > --- 
>> > output: 
>> > html_document: 
>> > pandoc_args: [ 
>> > "--number-offset=4,0" 
>> > ] 
>> > --- 
>> > 
>> > I tried different variations of this example, but none worked. Note, 
>> that 
>> > my input format ist pandoc markdown. 
>> > 
>> > It would be great, if something like that would work. I would appreciate 
>> > any help. 
>> > 
>> > Thanks in advance, 
>> > Karl 
>> > 
>> > 
>> > -- 
>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com. 
>>
>>
>
> -- 
> 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/1c0310ae-6348-4ba6-8d9d-746aab5e0c09n%40googlegroups.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]             ` <m2pn65208q.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-09-28 19:10               ` 'Karl Weber' via pandoc-discuss
       [not found]                 ` <c8b8ecf4-1f85-497d-ad85-aedeb96a4f2an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: 'Karl Weber' via pandoc-discuss @ 2020-09-28 19:10 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 4814 bytes --]

Hi John,

thanks, this should solve the --number-offset problem. Hence, I could close 
this thread, if I would know how :)

Nevertheless, now I am getting hooked on writing my own custom writer, or 
at least to understand how it would work. This brings me back to my 
questions in my previous post in this thread. Can I find some more 
documentation, should I open another thread for these questions or how 
should I procceed?

Thanks again in advance!
Karl

John MacFarlane schrieb am Montag, 28. September 2020 um 21:02:48 UTC+2:

>
> I wouldn't use a custom writer for this.
>
> An easier approach would be to use a wrapper shell script.
> The script would peek into the markdown file, find the
> setting for --number-offset, and call pandoc with the
> same arguments as the shell script PLUS the relevant
> --number-offset.
>
>
> "'Karl Weber' via pandoc-discuss"
> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:
>
> > Hi John,
> >
> > thank you for your answer. I would think it should be possible to do 
> that 
> > with my own custom writer (in Lua). Is that right?
> >
> > If so, how much work would it be? My starting point would be the 
> sample.lua 
> > obtained though the command
> >
> > pandoc --print-default-data-file sampla.lua
> >
> > Is there an easier way to do this? How close is this sample.lua to what 
> > pandoc is doing for output format html5? I.e. how much would I have to 
> add 
> > to sample.lua? Is it only my desired functionality or are there more 
> > differences? (I am using, for instance, --toc and --sections-div, which 
> > does not seem to be part of the sample.lua...) I did't find 
> > template-processing as well, but I am just starting to learn how to 
> build 
> > my own custom writer... 
> >
> > Im am using pandoc 2.10.1
> >
> > This solution (if feasible) would have the advantage, that I could add 
> more 
> > functionality I am currently missing (there may indeed be one or two 
> > things), but it would also have the disadvantage, that I would have to 
> > adapt my own custom writer, whenever pandoc evolves. However, this 
> should 
> > only be necessary if the datamodel of pandoc is changing, or isn't it? I 
> am 
> > still undecided.
> >
> > Thanks in advance
> > Karl
> >
> > John MacFarlane schrieb am Montag, 28. September 2020 um 01:02:41 UTC+2:
> >
> >>
> >> No, you can't specify it in YAML metadata. 
> >>
> >> "'Karl Weber' via pandoc-discuss" 
> >> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes: 
> >>
> >> > Hi, 
> >> > 
> >> > I do want to specify number-offset neither on the commandline of 
> pandoc 
> >> nor 
> >> > in the defaults yaml file. The reason is, that I have a project 
> >> consisting 
> >> > of a number of documents in markdown format, that I want to convert 
> to 
> >> > html5 using make. Hence I need to specify number-offset for each file 
> >> > individually. 
> >> > 
> >> > Is there some way to do this? 
> >> > 
> >> > I tried to specify it in a yaml block at the beginning of each file, 
> >> > something like the following: 
> >> > 
> >> > --- 
> >> > output: 
> >> > html_document: 
> >> > pandoc_args: [ 
> >> > "--number-offset=4,0" 
> >> > ] 
> >> > --- 
> >> > 
> >> > I tried different variations of this example, but none worked. Note, 
> >> that 
> >> > my input format ist pandoc markdown. 
> >> > 
> >> > It would be great, if something like that would work. I would 
> appreciate 
> >> > any help. 
> >> > 
> >> > Thanks in advance, 
> >> > Karl 
> >> > 
> >> > 
> >> > -- 
> >> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> >> > To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/pandoc-discuss/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com. 
>
> >>
> >>
> >
> > -- 
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/1c0310ae-6348-4ba6-8d9d-746aab5e0c09n%40googlegroups.com
> .
>

-- 
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/c8b8ecf4-1f85-497d-ad85-aedeb96a4f2an%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 7164 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]                 ` <c8b8ecf4-1f85-497d-ad85-aedeb96a4f2an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-28 21:53                   ` John MacFarlane
  0 siblings, 0 replies; 8+ messages in thread
From: John MacFarlane @ 2020-09-28 21:53 UTC (permalink / raw)
  To: 'Karl Weber' via pandoc-discuss, pandoc-discuss


I'm sorry, there's no documentation for custom writers beyond
what is in the manual and the sample.lua.

"'Karl Weber' via pandoc-discuss"
<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> Hi John,
>
> thanks, this should solve the --number-offset problem. Hence, I could close 
> this thread, if I would know how :)
>
> Nevertheless, now I am getting hooked on writing my own custom writer, or 
> at least to understand how it would work. This brings me back to my 
> questions in my previous post in this thread. Can I find some more 
> documentation, should I open another thread for these questions or how 
> should I procceed?
>
> Thanks again in advance!
> Karl
>
> John MacFarlane schrieb am Montag, 28. September 2020 um 21:02:48 UTC+2:
>
>>
>> I wouldn't use a custom writer for this.
>>
>> An easier approach would be to use a wrapper shell script.
>> The script would peek into the markdown file, find the
>> setting for --number-offset, and call pandoc with the
>> same arguments as the shell script PLUS the relevant
>> --number-offset.
>>
>>
>> "'Karl Weber' via pandoc-discuss"
>> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:
>>
>> > Hi John,
>> >
>> > thank you for your answer. I would think it should be possible to do 
>> that 
>> > with my own custom writer (in Lua). Is that right?
>> >
>> > If so, how much work would it be? My starting point would be the 
>> sample.lua 
>> > obtained though the command
>> >
>> > pandoc --print-default-data-file sampla.lua
>> >
>> > Is there an easier way to do this? How close is this sample.lua to what 
>> > pandoc is doing for output format html5? I.e. how much would I have to 
>> add 
>> > to sample.lua? Is it only my desired functionality or are there more 
>> > differences? (I am using, for instance, --toc and --sections-div, which 
>> > does not seem to be part of the sample.lua...) I did't find 
>> > template-processing as well, but I am just starting to learn how to 
>> build 
>> > my own custom writer... 
>> >
>> > Im am using pandoc 2.10.1
>> >
>> > This solution (if feasible) would have the advantage, that I could add 
>> more 
>> > functionality I am currently missing (there may indeed be one or two 
>> > things), but it would also have the disadvantage, that I would have to 
>> > adapt my own custom writer, whenever pandoc evolves. However, this 
>> should 
>> > only be necessary if the datamodel of pandoc is changing, or isn't it? I 
>> am 
>> > still undecided.
>> >
>> > Thanks in advance
>> > Karl
>> >
>> > John MacFarlane schrieb am Montag, 28. September 2020 um 01:02:41 UTC+2:
>> >
>> >>
>> >> No, you can't specify it in YAML metadata. 
>> >>
>> >> "'Karl Weber' via pandoc-discuss" 
>> >> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes: 
>> >>
>> >> > Hi, 
>> >> > 
>> >> > I do want to specify number-offset neither on the commandline of 
>> pandoc 
>> >> nor 
>> >> > in the defaults yaml file. The reason is, that I have a project 
>> >> consisting 
>> >> > of a number of documents in markdown format, that I want to convert 
>> to 
>> >> > html5 using make. Hence I need to specify number-offset for each file 
>> >> > individually. 
>> >> > 
>> >> > Is there some way to do this? 
>> >> > 
>> >> > I tried to specify it in a yaml block at the beginning of each file, 
>> >> > something like the following: 
>> >> > 
>> >> > --- 
>> >> > output: 
>> >> > html_document: 
>> >> > pandoc_args: [ 
>> >> > "--number-offset=4,0" 
>> >> > ] 
>> >> > --- 
>> >> > 
>> >> > I tried different variations of this example, but none worked. Note, 
>> >> that 
>> >> > my input format ist pandoc markdown. 
>> >> > 
>> >> > It would be great, if something like that would work. I would 
>> appreciate 
>> >> > any help. 
>> >> > 
>> >> > Thanks in advance, 
>> >> > Karl 
>> >> > 
>> >> > 
>> >> > -- 
>> >> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> >> > To view this discussion on the web visit 
>> >> 
>> https://groups.google.com/d/msgid/pandoc-discuss/200b15bc-f323-487e-b39d-e6be8845eacan%40googlegroups.com. 
>>
>> >>
>> >>
>> >
>> > -- 
>> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/1c0310ae-6348-4ba6-8d9d-746aab5e0c09n%40googlegroups.com
>> .
>>
>
> -- 
> 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/c8b8ecf4-1f85-497d-ad85-aedeb96a4f2an%40googlegroups.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to specify number-offset?
       [not found]             ` <90ec5cf3-3f74-4ae2-94a9-66d60d007ee1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-29  6:09               ` 'Karl Weber' via pandoc-discuss
  0 siblings, 0 replies; 8+ messages in thread
From: 'Karl Weber' via pandoc-discuss @ 2020-09-29  6:09 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 4377 bytes --]

I begin to understand pandoc a little better and one might really need only 
one enhancement, see last points (a) and (b) at the end.

Karl Weber schrieb am Montag, 28. September 2020 um 20:32:13 UTC+2:

> OK, I played around a little bit with sample.lua and have the following 
> understanding:
>
> (1) pandoc handles normal template usage in combination with sample.lua, I 
> only have to set --template=... on the commandline. Everything is fine.
>
> (2) Despite specifying --toc on the commandline, _no_ table of contents is 
> produced with sample.lua! It seems, that pandoc internally sets the content 
> for the table of contents to the metadata variable toc. In fact, if I add 
> some arbitrary text to the metadata variable toc, e.g. in a yaml block, 
> then a table of contents is printed with this text through my template. It 
> does not matter, if --toc is used or not.
>
> Question: How can I set the metadata variable toc in sample.lua? (I guess, 
> I would have to create the toc myself in sample.lua). I tied to modify 
> metadata in function Doc, but it didn't work.
>

One could create the table of contents in the function Doc(body, metadata, 
variables) in the custom writer in the same way as sample.lua does it with 
footnotes. It might indeed be the right way to do it because the toc 
belongs to the body. Only problem left: if it should be optional one needs 
to use a metadata variable to signal the custom writer to create a toc, 
because one does not have access to the commandline arguments.
 

> (3) Section numbering does not work with sample.lua. How can I get the 
> commandline arguments --number-sections and --number-offset=N in 
> sample.lua? I guess, I would also have to do the section numbering myself 
> in sample.lua.
>

Section numbering can be done with a simple lua filter, see answer to the 
next point (4). Unfortunately this solution will not support a 
--number-offset=N.
 

> (4) --sections-divs does not work in sample.lua. If I could read the 
> commandline argument --section-divs in sample.lua, I could write the 
> opening <section> tag in function Header. BUT: where and how could I create 
> the closing </section> tag? Maybe I would have to put a closing tag right 
> before the next opening tag in every call to function Header at the same or 
> lower level and add the last closing tag in function Doc to the body. Or is 
> there a better way? 
>

Section divs and section numbers can be added through a simple lua filter, 
so instead of writing --section-divs --section-numbers one needs to write 
--lua-filter sections.lua on the commandline, where sections.lua contains 
the following three lines of code:

function Pandoc(doc)
    return pandoc.Pandoc(pandoc.utils.make_sections(true, 1, doc.blocks), 
doc.meta)
end

I think it is even better to do this through a lua filter instead of in a 
custom writer.

So there seem to be only two questions left:

(a) How can one obtain the commandline arguments pandoc was run with in lua 
filters and in lua custom writers? If there is no way to get these, one 
could in principal use metadata as a workaround. One can in principle live 
with this workaround, but it is not really nice if one wants to use pandoc 
to create more than one format from an input file. The control of what 
pandoc is doing would depend on the format. So would it be possible to 
provide commandline arguments readonly through some global variable to lua 
filters and lua custom writers? I think this would be great.

(b) The function pandoc.utils.make_section(number_sections, base_level, 
blocks) is not respecting the commandline argument --number-offset. Is this 
a bug or should this function get another parameter like the following: 
pandoc.utils.make_section(number_sections, number_offset, base_level, 
blocks)? Would there be any change, to get this as an enhancement? I think 
it would also be great.

Would it be undue to ask for these two enhancements?
 
Regards
Karl

-- 
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/2673537e-9b7b-4acb-9af8-43598e6cef1bn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 5539 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-29  6:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27 17:07 How to specify number-offset? 'Karl Weber' via pandoc-discuss
     [not found] ` <200b15bc-f323-487e-b39d-e6be8845eacan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-27 23:02   ` John MacFarlane
     [not found]     ` <m2v9fy258g.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-09-28  6:08       ` 'Karl Weber' via pandoc-discuss
     [not found]         ` <1c0310ae-6348-4ba6-8d9d-746aab5e0c09n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-28 18:32           ` 'Karl Weber' via pandoc-discuss
     [not found]             ` <90ec5cf3-3f74-4ae2-94a9-66d60d007ee1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-29  6:09               ` 'Karl Weber' via pandoc-discuss
2020-09-28 19:02           ` John MacFarlane
     [not found]             ` <m2pn65208q.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-09-28 19:10               ` 'Karl Weber' via pandoc-discuss
     [not found]                 ` <c8b8ecf4-1f85-497d-ad85-aedeb96a4f2an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-28 21:53                   ` John MacFarlane

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).