public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to change section dividers from div/section to li?
@ 2015-07-04  6:55 Diego Algorta
       [not found] ` <041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Diego Algorta @ 2015-07-04  6:55 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

Hi,

(in case the code examples don't render well, you can see the same 
here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd)

I basically need to use ordered lists for sections instead of div or 
section.

Given this input:

```markdown

Independent paragraph.
 
# My heading 1
 
Para in heading 1.
 
## My heading 2
 
Para in heading 2
 
# Another heading 1
 
With its own para.
```

Running pandoc with `--section-divs -t html5` currently produces:

```html

<p>Independent paragraph.</p>
<section id="my-heading-1" class="level1">
  <h1>My heading 1</h1>
  <p>Para in heading 1.</p>
  <section id="my-heading-2" class="level2">
    <h2>My heading 2</h2>
    <p>Para in heading 2</p>
  </section>
</section>
<section id="another-heading-1" class="level1">
  <h1>Another heading 1</h1>
  <p>With its own para.</p>

</section>
```

Can you think of the best way to change that (maybe a filter?) so that I 
get this instead?:

```html

<p>Independent paragraph.</p>
<ol>
  <li id="my-heading-1" class="level1">
    <h1>My heading 1</h1>
    <p>Para in heading 1.</p>
    <ol>
      <li id="my-heading-2" class="level2">
        <h2>My heading 2</h2>
        <p>Para in heading 2</p>
      </li>
    </ol>
  </li>
  <li id="another-heading-1" class="level1">
    <h1>Another heading 1</h1>
    <p>With its own para.</p>
  </li>
</ol>

```

I'm gaining experience writing nodejs based filters, in case that helps. 
But this seems to be out of the scope of filters, am I right?

Thanks!
Diego

-- 
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/041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found] ` <041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-07-04  7:01   ` Diego Algorta
  2015-07-04  8:23   ` Pablo Rodríguez
  2015-07-04 22:24   ` John MacFarlane
  2 siblings, 0 replies; 14+ messages in thread
From: Diego Algorta @ 2015-07-04  7:01 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I forgot to mention, I know about the `--number-sections` command line
parameter. But that won't cut it. I need Ordered Lists.

On Sat, Jul 4, 2015 at 3:55 AM, Diego Algorta <diego-X9ybnTC+vipBDgjK7y7TUQ@public.gmane.org> wrote:

> Hi,
>
> (in case the code examples don't render well, you can see the same here:
> https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd)
>
> I basically need to use ordered lists for sections instead of div or
> section.
>
> Given this input:
>
> ```markdown
>
> Independent paragraph.
>
> # My heading 1
>
> Para in heading 1.
>
> ## My heading 2
>
> Para in heading 2
>
> # Another heading 1
>
> With its own para.
> ```
>
> Running pandoc with `--section-divs -t html5` currently produces:
>
> ```html
>
> <p>Independent paragraph.</p>
> <section id="my-heading-1" class="level1">
>   <h1>My heading 1</h1>
>   <p>Para in heading 1.</p>
>   <section id="my-heading-2" class="level2">
>     <h2>My heading 2</h2>
>     <p>Para in heading 2</p>
>   </section>
> </section>
> <section id="another-heading-1" class="level1">
>   <h1>Another heading 1</h1>
>   <p>With its own para.</p>
>
> </section>
> ```
>
> Can you think of the best way to change that (maybe a filter?) so that I
> get this instead?:
>
> ```html
>
> <p>Independent paragraph.</p>
> <ol>
>   <li id="my-heading-1" class="level1">
>     <h1>My heading 1</h1>
>     <p>Para in heading 1.</p>
>     <ol>
>       <li id="my-heading-2" class="level2">
>         <h2>My heading 2</h2>
>         <p>Para in heading 2</p>
>       </li>
>     </ol>
>   </li>
>   <li id="another-heading-1" class="level1">
>     <h1>Another heading 1</h1>
>     <p>With its own para.</p>
>   </li>
> </ol>
>
> ```
>
> I'm gaining experience writing nodejs based filters, in case that helps.
> But this seems to be out of the scope of filters, am I right?
>
> Thanks!
> Diego
>
>  --
> 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/qMCJN1dCgkY/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/041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Algorta : ob.oxo.do

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

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

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

* Re: How to change section dividers from div/section to li?
       [not found] ` <041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-07-04  7:01   ` Diego Algorta
@ 2015-07-04  8:23   ` Pablo Rodríguez
       [not found]     ` <559797E8.6050100-S0/GAf8tV78@public.gmane.org>
  2015-07-04 22:24   ` John MacFarlane
  2 siblings, 1 reply; 14+ messages in thread
From: Pablo Rodríguez @ 2015-07-04  8:23 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 07/04/2015 08:55 AM, Diego Algorta wrote:
> Hi,
> 
> (in case the code examples don't render well, you can see the same
> here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd)
> 
> I basically need to use ordered lists for sections instead of div or
> section.

Hi Diego,

may I ask why do you need ordered lists instead of divs or sections? (I
suspect that you may get the same results with sections or divs and with
the proper CSS code.)

You’ll get ordered lists with the following source:

``` markdown
Independent paragraph.

1. # My heading 1

    Para in heading 1.

1. ## My heading 2

    Para in heading 2

1. # Another heading 1

    With its own para.
```

But you won’t get list items with heading attributes:
http://pandoc.org/try/?text=Independent+paragraph.%0A+%0A1.+%23+My+heading+1%0A+%0A++++Para+in+heading+1.%0A+%0A1.+%23%23+My+heading+2%0A+%0A++++Para+in+heading+2%0A+%0A1.+%23+Another+heading+1%0A+%0A++++With+its+own+para.&from=markdown&to=html5.


Pablo


> Given this input:
> 
> ```markdown
> 
> Independent paragraph.
>  
> # My heading 1
>  
> Para in heading 1.
>  
> ## My heading 2
>  
> Para in heading 2
>  
> # Another heading 1
>  
> With its own para.
> ```
> 
> Running pandoc with `--section-divs -t html5` currently produces:
> 
> ```html
> 
> <p>Independent paragraph.</p>
> <section id="my-heading-1" class="level1">
> <h1>My heading 1</h1>
> <p>Para in heading 1.</p>
> <section id="my-heading-2" class="level2">
> <h2>My heading 2</h2>
> <p>Para in heading 2</p>
> </section>
> </section>
> <section id="another-heading-1" class="level1">
> <h1>Another heading 1</h1>
> <p>With its own para.</p>
> 
> </section>
> ```
> 
> Can you think of the best way to change that (maybe a filter?) so that I
> get this instead?:
> 
> ```html
> 
> <p>Independent paragraph.</p>
> <ol>
> <li id="my-heading-1" class="level1">
> <h1>My heading 1</h1>
> <p>Para in heading 1.</p>
> <ol>
> <li id="my-heading-2" class="level2">
> <h2>My heading 2</h2>
> <p>Para in heading 2</p>
> </li>
> </ol>
> </li>
> <li id="another-heading-1" class="level1">
> <h1>Another heading 1</h1>
> <p>With its own para.</p>
> </li>
> </ol>
> 
> ```
> 
> I'm gaining experience writing nodejs based filters, in case that helps.
> But this seems to be out of the scope of filters, am I right?
> 
> Thanks!
> Diego


-- 
http://www.ousia.tk

-- 
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/559797E8.6050100%40web.de.
For more options, visit https://groups.google.com/d/optout.


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

* Re: How to change section dividers from div/section to li?
       [not found]     ` <559797E8.6050100-S0/GAf8tV78@public.gmane.org>
@ 2015-07-04 15:54       ` Diego Algorta
       [not found]         ` <d9d34f5d-570c-44ee-85fc-b3e15aa510cd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Diego Algorta @ 2015-07-04 15:54 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

On Saturday, July 4, 2015 at 5:23:12 AM UTC-3, ousia wrote:
>
> On 07/04/2015 08:55 AM, Diego Algorta wrote: 
> > Hi, 
> > 
> > (in case the code examples don't render well, you can see the same 
> > here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd) 
> > 
> > I basically need to use ordered lists for sections instead of div or 
> > section. 
>
> Hi Diego, 
>
> may I ask why do you need ordered lists instead of divs or sections? (I 
> suspect that you may get the same results with sections or divs and with 
> the proper CSS code.) 
>
> You’ll get ordered lists with the following source: 
>
> ``` markdown 
> Independent paragraph. 
>
> 1. # My heading 1 
>
>     Para in heading 1. 
>
> 1. ## My heading 2 
>
>     Para in heading 2 
>
> 1. # Another heading 1 
>
>     With its own para. 
> ``` 
>
>
Hi Pablo, thanks for your quick reply.

Yes, I know that sample source generates an ordered list and that's exactly 
what I want to generate. But I don't have that source. I think I'll have to 
explain a bit more... I've explained a bit in previous posts but I've got 
some progress since and changed my mind about some others.

I'm needing to import a bunch of big (200+ pages) `docx` files to our 
system. Then from our system I'll need to render those as good 
`html`/`html5` and most probably I'll also have to export to `docx` and 
`pdf` at the very least.

These source `docx` files "look" ok in Word, but according to what I get 
from pandoc when converting it, they're semantically very wrong. I can't 
ask the original writers to "fix" these semantic/formatting problems in 
Word because it (sadly) requires very decent Word skills and, to be honest, 
they don't "see" the problems in Word.

As an example, here you have a screenshot from Word: 
https://www.evernote.com/l/AXVBYI_vPGBK3K42nTGFZ8Qfl_Uu5_UienYB/image.png

Converting that to markdown with `-t markdown -S --atx-headers` produces 
the following result where you can witness a lot of semantic/formatting 
errors which are "transparent" to the Word 
user: https://gist.githubusercontent.com/oboxodo/1316e02b16cda679aee4/raw/1459271e1787174cb2aa510e2fbd7d9323eef41f/criminal_law-S--atx-headers.md

As you can see there's a bunch of problems in there, and this is just a 
sample from a 200+ pages document. Some of the problems are:
* Use of hard line breaks to separate the "header" from the next paragraph.
* Improper indentation which causes ordered lists to break the sequence.
* Improper indentation causing some paragraphs to be considered blockquotes.

For good or bad, there's a few rules I need to satisfy for the end result:
* Indentation levels MUST follow these numbering schemes: 'UpperRoman':1, 
'UpperAlpha':2, 'Decimal':3, 'LowerAlpha':4, 'LowerRoman':5. (this is why 
`--number-sections` is no good)
* Every first paragraph in a list item is that item's heading and MUST be 
anchored in order to generate a TOC.
* I can assume there's no blockquotes.

So I've managed to develop a set of filters which solve most of these 
problems. Right now I'm able to generate this from the same 
source: https://gist.githubusercontent.com/oboxodo/835670dff0f20c744a01/raw/43bbc2e7d509cc7e49b576f2c1dc578d44e615a1/criminal_law-S--atx-headers-processed.md

As you can see... I'm VERY close! I really don't care if the heading 
attributes are in the `li` or the `h1/2/3...`. But I need the sections to 
be on OrderedLists :)

-- 
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/d9d34f5d-570c-44ee-85fc-b3e15aa510cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found]         ` <d9d34f5d-570c-44ee-85fc-b3e15aa510cd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-07-04 16:36           ` Diego Algorta
       [not found]             ` <5be3cf89-2604-4a51-8cec-3175198fecc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Diego Algorta @ 2015-07-04 16:36 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

On Saturday, July 4, 2015 at 12:54:40 PM UTC-3, Diego Algorta wrote:
>
> On Saturday, July 4, 2015 at 5:23:12 AM UTC-3, ousia wrote:
>>
>> On 07/04/2015 08:55 AM, Diego Algorta wrote: 
>> > Hi, 
>> > 
>> > (in case the code examples don't render well, you can see the same 
>> > here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd) 
>> > 
>> > I basically need to use ordered lists for sections instead of div or 
>> > section. 
>>
>> Hi Diego, 
>>
>> may I ask why do you need ordered lists instead of divs or sections? (I 
>> suspect that you may get the same results with sections or divs and with 
>> the proper CSS code.) 
>>
>> You’ll get ordered lists with the following source: 
>>
>> ``` markdown 
>> Independent paragraph. 
>>
>> 1. # My heading 1 
>>
>>     Para in heading 1. 
>>
>> 1. ## My heading 2 
>>
>>     Para in heading 2 
>>
>> 1. # Another heading 1 
>>
>>     With its own para. 
>> ``` 
>>
>>
> Hi Pablo, thanks for your quick reply.
>
> Yes, I know that sample source generates an ordered list and that's 
> exactly what I want to generate. But I don't have that source. I think I'll 
> have to explain a bit more... I've explained a bit in previous posts but 
> I've got some progress since and changed my mind about some others.
>
> I'm needing to import a bunch of big (200+ pages) `docx` files to our 
> system. Then from our system I'll need to render those as good 
> `html`/`html5` and most probably I'll also have to export to `docx` and 
> `pdf` at the very least.
>
> These source `docx` files "look" ok in Word, but according to what I get 
> from pandoc when converting it, they're semantically very wrong. I can't 
> ask the original writers to "fix" these semantic/formatting problems in 
> Word because it (sadly) requires very decent Word skills and, to be honest, 
> they don't "see" the problems in Word.
>
> As an example, here you have a screenshot from Word: 
> https://www.evernote.com/l/AXVBYI_vPGBK3K42nTGFZ8Qfl_Uu5_UienYB/image.png
>
> Converting that to markdown with `-t markdown -S --atx-headers` produces 
> the following result where you can witness a lot of semantic/formatting 
> errors which are "transparent" to the Word user: 
> https://gist.githubusercontent.com/oboxodo/1316e02b16cda679aee4/raw/1459271e1787174cb2aa510e2fbd7d9323eef41f/criminal_law-S--atx-headers.md
>
> As you can see there's a bunch of problems in there, and this is just a 
> sample from a 200+ pages document. Some of the problems are:
> * Use of hard line breaks to separate the "header" from the next paragraph.
> * Improper indentation which causes ordered lists to break the sequence.
> * Improper indentation causing some paragraphs to be considered 
> blockquotes.
>
> For good or bad, there's a few rules I need to satisfy for the end result:
> * Indentation levels MUST follow these numbering schemes: 'UpperRoman':1, 
> 'UpperAlpha':2, 'Decimal':3, 'LowerAlpha':4, 'LowerRoman':5. (this is why 
> `--number-sections` is no good)
> * Every first paragraph in a list item is that item's heading and MUST be 
> anchored in order to generate a TOC.
> * I can assume there's no blockquotes.
>
> So I've managed to develop a set of filters which solve most of these 
> problems. Right now I'm able to generate this from the same source: 
> https://gist.githubusercontent.com/oboxodo/835670dff0f20c744a01/raw/43bbc2e7d509cc7e49b576f2c1dc578d44e615a1/criminal_law-S--atx-headers-processed.md
>
> As you can see... I'm VERY close! I really don't care if the heading 
> attributes are in the `li` or the `h1/2/3...`. But I need the sections to 
> be on OrderedLists :)
>

I forgot to mention, this is the final result I'm looking for (this one I 
crafter manually): 
https://gist.githubusercontent.com/oboxodo/786e857cf0fef4d2be41/raw/d39b458ae6a33216fdbcd67bd24cfeabbb9e9f46/criminal_law-S--atx-headers-final.md

The `html` and `docx` pandoc generates from that is fantastic. *So the only 
step I'm missing is*: Nesting sections in OrderedLists instead of 
`div`/`section` elements.

Diego

-- 
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/5be3cf89-2604-4a51-8cec-3175198fecc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found]             ` <5be3cf89-2604-4a51-8cec-3175198fecc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-07-04 17:44               ` Pablo Rodríguez
       [not found]                 ` <55981B70.4080409-S0/GAf8tV78@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Pablo Rodríguez @ 2015-07-04 17:44 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 07/04/2015 06:36 PM, Diego Algorta wrote:
> [...]
> The `html` and `docx` pandoc generates from that is fantastic. *So the
> only step I'm missing is*: Nesting sections in OrderedLists instead of
> `div`/`section` elements.

Hi Diego,

unless I’m missing something, the following CSS code should do what you
intend without ordered lists:

.level1, .level2, .level3, .level4, .level5 {
    margin-left:5%;
    }

body {
    counter-reset: part;
    }

.level1 > h1:before {
    content: counter(part, upper-roman) ". ";
    counter-increment: part;
    counter-reset: chapter;
    }

.level2 > h2:before {
    content: counter(chapter, upper-latin) ". ";
    counter-increment: chapter;
    counter-reset: section;
    }

.level3 > h3:before {
    content: counter(section, decimal) ". ";
    counter-increment: section;
    counter-reset: subsection;
    }

.level4 > h4:before {
    content: counter(subsection, lower-latin) ". ";
    counter-increment: subsection;
    counter-reset: subsubsection;
    }

.level5 > h5:before {
    content: counter(subsubsection, lower-roman) ". ";
    counter-increment: subsubsection;
    }

.level1 > h1, .level2 > h2, .level3 > h3, .level4 > h4, .level5 > h5 {
    margin-left: -1.5em;
    }

I hope it helps,


Pablo
-- 
http://www.ousia.tk

-- 
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/55981B70.4080409%40web.de.
For more options, visit https://groups.google.com/d/optout.


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

* Re: How to change section dividers from div/section to li?
       [not found] ` <041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-07-04  7:01   ` Diego Algorta
  2015-07-04  8:23   ` Pablo Rodríguez
@ 2015-07-04 22:24   ` John MacFarlane
       [not found]     ` <20150704222450.GC11787-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  2 siblings, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2015-07-04 22:24 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

You can use `hierarchicalize` in `Text.Pandoc.Shared` to
create a hierarchical structure from the sections (the way
`--section-divs` does).

Once you've got that, you should be able to convert this
structure to an ordered list.

All of this could be done in a (Haskell) filter.  If you
have questions, let me know.

+++ Diego Algorta [Jul 03 15 23:55 ]:
>   Hi,
>   (in case the code examples don't render well, you can see the same
>   here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd)
>   I basically need to use ordered lists for sections instead of div or
>   section.
>   Given this input:
>   ```markdown
>
>   Independent paragraph.
>
>   # My heading 1
>
>   Para in heading 1.
>
>   ## My heading 2
>
>   Para in heading 2
>
>   # Another heading 1
>
>   With its own para.
>   ```
>   Running pandoc with `--section-divs -t html5` currently produces:
>   ```html
>
>   <p>Independent paragraph.</p>
>   <section id="my-heading-1" class="level1">
>   <h1>My heading 1</h1>
>   <p>Para in heading 1.</p>
>   <section id="my-heading-2" class="level2">
>   <h2>My heading 2</h2>
>   <p>Para in heading 2</p>
>   </section>
>   </section>
>   <section id="another-heading-1" class="level1">
>   <h1>Another heading 1</h1>
>   <p>With its own para.</p>
>   </section>
>   ```
>   Can you think of the best way to change that (maybe a filter?) so that
>   I get this instead?:
>   ```html
>
>   <p>Independent paragraph.</p>
>   <ol>
>   <li id="my-heading-1" class="level1">
>   <h1>My heading 1</h1>
>   <p>Para in heading 1.</p>
>   <ol>
>   <li id="my-heading-2" class="level2">
>   <h2>My heading 2</h2>
>   <p>Para in heading 2</p>
>   </li>
>   </ol>
>   </li>
>   <li id="another-heading-1" class="level1">
>   <h1>Another heading 1</h1>
>   <p>With its own para.</p>
>   </li>
>   </ol>
>
>   ```
>
>   I'm gaining experience writing nodejs based filters, in case that
>   helps. But this seems to be out of the scope of filters, am I right?
>
>   Thanks!
>
>   Diego
>
>   --
>   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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [3]https://groups.google.com/d/msgid/pandoc-discuss/041499d2-158c-4dc9-
>   b6d8-b5f8c0e0c3a0%40googlegroups.com.
>   For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   3. https://groups.google.com/d/msgid/pandoc-discuss/041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout


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

* Re: How to change section dividers from div/section to li?
       [not found]                 ` <55981B70.4080409-S0/GAf8tV78@public.gmane.org>
@ 2015-07-05  0:52                   ` Diego Algorta
  0 siblings, 0 replies; 14+ messages in thread
From: Diego Algorta @ 2015-07-05  0:52 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

On Saturday, July 4, 2015 at 2:44:24 PM UTC-3, ousia wrote:
>
> On 07/04/2015 06:36 PM, Diego Algorta wrote: 
> > [...] 
> > The `html` and `docx` pandoc generates from that is fantastic. *So the 
> > only step I'm missing is*: Nesting sections in OrderedLists instead of 
> > `div`/`section` elements. 
>
> Hi Diego, 
>
> unless I’m missing something, the following CSS code should do what you 
> intend without ordered lists: 
>
>
Pablo, thanks for your CSS masterclass!

I haven't tried this yet, but it reads nice and understandable. That said, 
this would be a "cosmetic" workaround which would work only for HTML. I 
will certainly go this way if I can't solve it directly by altering the AST 
via a filter.

Thanks again for your quick help.

-- 
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/ce9a7149-4ec8-41be-9110-0e1c66910af6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found]     ` <20150704222450.GC11787-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-07-05  1:02       ` Diego Algorta
       [not found]         ` <CAPfjgvJxjrE0E5=u1saMH8NPvRWf9Rb4PURmeiKFQ+xx7Zqyrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Diego Algorta @ 2015-07-05  1:02 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

John, `hierarchicalize` is exactly the kind of help I was looking for!

I've been reading the code and how you use it, but my Haskell-fu is almost
non-existent and understanding it is becoming a daunting task. I have zero
experience with Haskell and last few years I've been coding almost
exclusively in Ruby and some JS. I would certainly appreciate some
pseudocode on how I could approach this filter.

Maybe if I get to understand how Hierarchicalize works, I could port it to
JS and send a pull request to pandoc-filter-node? That would allow me to
code the filter in JS which would be way easier for me... (and presumably
useful to others too).

Thanks in advance for any guidance you could provide.

Diego

On Sat, Jul 4, 2015 at 7:24 PM, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

> You can use `hierarchicalize` in `Text.Pandoc.Shared` to
> create a hierarchical structure from the sections (the way
> `--section-divs` does).
>
> Once you've got that, you should be able to convert this
> structure to an ordered list.
>
> All of this could be done in a (Haskell) filter.  If you
> have questions, let me know.
>
> +++ Diego Algorta [Jul 03 15 23:55 ]:
>
>>   Hi,
>>   (in case the code examples don't render well, you can see the same
>>   here: https://gist.github.com/oboxodo/f514d3bfe894bc1c85bd)
>>   I basically need to use ordered lists for sections instead of div or
>>   section.
>>   Given this input:
>>   ```markdown
>>
>>   Independent paragraph.
>>
>>   # My heading 1
>>
>>   Para in heading 1.
>>
>>   ## My heading 2
>>
>>   Para in heading 2
>>
>>   # Another heading 1
>>
>>   With its own para.
>>   ```
>>   Running pandoc with `--section-divs -t html5` currently produces:
>>   ```html
>>
>>   <p>Independent paragraph.</p>
>>   <section id="my-heading-1" class="level1">
>>   <h1>My heading 1</h1>
>>   <p>Para in heading 1.</p>
>>   <section id="my-heading-2" class="level2">
>>   <h2>My heading 2</h2>
>>   <p>Para in heading 2</p>
>>   </section>
>>   </section>
>>   <section id="another-heading-1" class="level1">
>>   <h1>Another heading 1</h1>
>>   <p>With its own para.</p>
>>   </section>
>>   ```
>>   Can you think of the best way to change that (maybe a filter?) so that
>>   I get this instead?:
>>   ```html
>>
>>   <p>Independent paragraph.</p>
>>   <ol>
>>   <li id="my-heading-1" class="level1">
>>   <h1>My heading 1</h1>
>>   <p>Para in heading 1.</p>
>>   <ol>
>>   <li id="my-heading-2" class="level2">
>>   <h2>My heading 2</h2>
>>   <p>Para in heading 2</p>
>>   </li>
>>   </ol>
>>   </li>
>>   <li id="another-heading-1" class="level1">
>>   <h1>Another heading 1</h1>
>>   <p>With its own para.</p>
>>   </li>
>>   </ol>
>>
>>   ```
>>
>>   I'm gaining experience writing nodejs based filters, in case that
>>   helps. But this seems to be out of the scope of filters, am I right?
>>
>>   Thanks!
>>
>>   Diego
>>
>>   --
>>   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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>   To post to this group, send email to
>>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>   To view this discussion on the web visit
>>   [3]https://groups.google.com/d/msgid/pandoc-discuss/041499d2-158c-4dc9-
>>   b6d8-b5f8c0e0c3a0%40googlegroups.com.
>>   For more options, visit [4]https://groups.google.com/d/optout.
>>
>> References
>>
>>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>   3.
>> https://groups.google.com/d/msgid/pandoc-discuss/041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>>   4. 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/qMCJN1dCgkY/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/20150704222450.GC11787%40localhost.hsd1.ca.comcast.net
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Algorta : ob.oxo.do

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

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

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

* Re: How to change section dividers from div/section to li?
       [not found]         ` <CAPfjgvJxjrE0E5=u1saMH8NPvRWf9Rb4PURmeiKFQ+xx7Zqyrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-07-05  4:06           ` John MacFarlane
       [not found]             ` <20150705040611.GA12677-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2015-07-05  4:06 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Here's a filter that will convert a document structured by
headings into one structured by ordered lists:

``` haskell
import Text.Pandoc.JSON
import Text.Pandoc.Shared

main = toJSONFilter headersToOrdered

headersToOrdered :: Pandoc -> Pandoc
headersToOrdered (Pandoc m bs) = Pandoc m
  [OrderedList (1, Decimal, Period)
     $ map elementToBlocks
     $ hierarchicalize bs]

elementToBlocks :: Element -> [Block]
elementToBlocks (Blk b) = [b]
elementToBlocks (Sec lev _ _ ils []) = [Para ils]
elementToBlocks (Sec lev _ _ ils es) =
  [Para ils, OrderedList (1, Decimal, Period) $ map elementToBlocks es]
```


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

* Re: How to change section dividers from div/section to li?
       [not found]             ` <20150705040611.GA12677-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-07-05 16:24               ` John MacFarlane
       [not found]                 ` <20150705162410.GA14096-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: John MacFarlane @ 2015-07-05 16:24 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Oh, if you want the list number style to change with
the level, use `--number-sections` and change the script as
follows:


``` haskell
import Text.Pandoc.JSON
import Text.Pandoc.Shared

main = toJSONFilter headersToOrdered

headersToOrdered :: Pandoc -> Pandoc
headersToOrdered (Pandoc m bs) = Pandoc m
 [OrderedList (1, Decimal, Period)
    $ map elementToBlocks
    $ hierarchicalize bs]

elementToBlocks :: Element -> [Block]
elementToBlocks (Blk b) = [b]
elementToBlocks (Sec lev _ _ ils []) = [Para ils]
elementToBlocks (Sec lev secs _ ils es) =
 let listType = cycle [ Decimal
                      , UpperAlpha
                      , LowerAlpha
                      , UpperRoman
                      , LowerRoman ] !! (length secs - 1)
 [Para ils, OrderedList (1, listType, Period) $ map elementToBlocks es]
```


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

* Re: How to change section dividers from div/section to li?
       [not found]                 ` <20150705162410.GA14096-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2015-07-05 16:37                   ` fiddlosopher
       [not found]                     ` <ffc909e4-ed88-4852-a6a4-26f9a6f5162a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: fiddlosopher @ 2015-07-05 16:37 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, jgm-TVLZxgkOlNX2fBVCVOL8/A


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

Forgot an "in":

``` haskell 
> import Text.Pandoc.JSON 
> import Text.Pandoc.Shared 
>
> main = toJSONFilter headersToOrdered 
>
> headersToOrdered :: Pandoc -> Pandoc 
> headersToOrdered (Pandoc m bs) = Pandoc m 
>  [OrderedList (1, Decimal, Period) 
>     $ map elementToBlocks 
>     $ hierarchicalize bs] 
>
> elementToBlocks :: Element -> [Block] 
> elementToBlocks (Blk b) = [b] 
> elementToBlocks (Sec lev _ _ ils []) = [Para ils] 
> elementToBlocks (Sec lev secs _ ils es) = 
>  let listType = cycle [ Decimal 
>                       , UpperAlpha 
>                       , LowerAlpha 
>                       , UpperRoman 
>                       , LowerRoman ] !! (length secs - 1) 
>  in [Para ils, OrderedList (1, listType, Period) $ map elementToBlocks es] 
> ``` 
>

-- 
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/ffc909e4-ed88-4852-a6a4-26f9a6f5162a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found]                     ` <ffc909e4-ed88-4852-a6a4-26f9a6f5162a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-07-05 17:24                       ` fiddlosopher
       [not found]                         ` <ad4bf09c-2d32-44b7-9e69-f3d45c74ae54-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: fiddlosopher @ 2015-07-05 17:24 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw,
	fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w
  Cc: jgm-TVLZxgkOlNX2fBVCVOL8/A


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

Here's an updated version of the filter that (a) uses the sequence of list 
styles you specified, (b) includes a div with an id around the first 
paragraph in each ordered list item.  Run with `--number-sections`.

```
import Text.Pandoc.JSON

import Text.Pandoc.Shared


main :: IO ()

main = toJSONFilter headersToOrdered


headersToOrdered :: Pandoc -> Pandoc

headersToOrdered (Pandoc m bs) = Pandoc m [OrderedList (1, UpperRoman, 
Period)

                                           $ map elementToBlocks

                                           $ hierarchicalize bs]


elementToBlocks :: Element -> [Block]

elementToBlocks (Blk b) = [b]

elementToBlocks (Sec lev _ attr ils []) = [Div attr [Para ils]]

elementToBlocks (Sec lev secs attr ils es) =

  let listType = cycle [ UpperRoman

                       , UpperAlpha

                       , Decimal

                       , LowerAlpha

                       , LowerRoman

                       ] !! (length secs)

  in [ Div attr [Para ils]

     , OrderedList (1, listType, Period) $ map elementToBlocks es]

```


-- 
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/ad4bf09c-2d32-44b7-9e69-f3d45c74ae54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

* Re: How to change section dividers from div/section to li?
       [not found]                         ` <ad4bf09c-2d32-44b7-9e69-f3d45c74ae54-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-07-06 18:23                           ` Diego Algorta
  0 siblings, 0 replies; 14+ messages in thread
From: Diego Algorta @ 2015-07-06 18:23 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw; +Cc: jgm-TVLZxgkOlNX2fBVCVOL8/A


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

First of all, thank you both very much. We're getting close!

Given this filter:
```haskell
#!/usr/bin/env runhaskell
-- pandoc filter

import Text.Pandoc.JSON
import Text.Pandoc.Shared

main = toJSONFilter headersToOrdered

headersToOrdered :: Pandoc -> Pandoc
headersToOrdered (Pandoc m bs) = Pandoc m
 [OrderedList (1, UpperRoman, Period)
    $ map elementToBlocks
    $ hierarchicalize bs]

elementToBlocks :: Element -> [Block]
elementToBlocks (Blk b) = [b]
elementToBlocks (Sec lev _ _ ils []) = [Para ils]
elementToBlocks (Sec lev secs _ ils es) =
 let listType = cycle [ UpperRoman
                      , UpperAlpha
                      , Decimal
                      , LowerAlpha
                      , LowerRoman ] !! (length secs)
 in [Para ils, OrderedList (1, listType, Period) $ map elementToBlocks es]
```

And this 
source: https://gist.githubusercontent.com/oboxodo/835670dff0f20c744a01/raw/43bbc2e7d509cc7e49b576f2c1dc578d44e615a1/criminal_law-S--atx-headers-processed.md

This is what I'm 
getting: https://gist.githubusercontent.com/oboxodo/64cb8fb1945da8a069aa/raw/c641ee53acb74c15a3fff1692801067e7aad4a21/criminal_law-S--atx-headers-filtered-v1.md

And this is what I 
need: https://gist.githubusercontent.com/oboxodo/786e857cf0fef4d2be41/raw/d39b458ae6a33216fdbcd67bd24cfeabbb9e9f46/criminal_law-S--atx-headers-final.md

As you can see, there's 2 problems:
1. Headers are lost and they're converted into Paras.
2. Normal Paras are being converted into lis themselves.

I've been trying to fix this to no avail :(

Thoughts?

Thanks again.

On Sunday, July 5, 2015 at 2:24:35 PM UTC-3, fiddlosopher wrote:
>
> Here's an updated version of the filter that (a) uses the sequence of list 
> styles you specified, (b) includes a div with an id around the first 
> paragraph in each ordered list item.  Run with `--number-sections`.
>
> ```
> import Text.Pandoc.JSON
>
> import Text.Pandoc.Shared
>
>
> main :: IO ()
>
> main = toJSONFilter headersToOrdered
>
>
> headersToOrdered :: Pandoc -> Pandoc
>
> headersToOrdered (Pandoc m bs) = Pandoc m [OrderedList (1, UpperRoman, 
> Period)
>
>                                            $ map elementToBlocks
>
>                                            $ hierarchicalize bs]
>
>
> elementToBlocks :: Element -> [Block]
>
> elementToBlocks (Blk b) = [b]
>
> elementToBlocks (Sec lev _ attr ils []) = [Div attr [Para ils]]
>
> elementToBlocks (Sec lev secs attr ils es) =
>
>   let listType = cycle [ UpperRoman
>
>                        , UpperAlpha
>
>                        , Decimal
>
>                        , LowerAlpha
>
>                        , LowerRoman
>
>                        ] !! (length secs)
>
>   in [ Div attr [Para ils]
>
>      , OrderedList (1, listType, Period) $ map elementToBlocks es]
>
> ```
>
>
>

-- 
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/4e3a8703-4c33-4574-9230-4df1ac9b6d93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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

end of thread, other threads:[~2015-07-06 18:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-04  6:55 How to change section dividers from div/section to li? Diego Algorta
     [not found] ` <041499d2-158c-4dc9-b6d8-b5f8c0e0c3a0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-07-04  7:01   ` Diego Algorta
2015-07-04  8:23   ` Pablo Rodríguez
     [not found]     ` <559797E8.6050100-S0/GAf8tV78@public.gmane.org>
2015-07-04 15:54       ` Diego Algorta
     [not found]         ` <d9d34f5d-570c-44ee-85fc-b3e15aa510cd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-07-04 16:36           ` Diego Algorta
     [not found]             ` <5be3cf89-2604-4a51-8cec-3175198fecc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-07-04 17:44               ` Pablo Rodríguez
     [not found]                 ` <55981B70.4080409-S0/GAf8tV78@public.gmane.org>
2015-07-05  0:52                   ` Diego Algorta
2015-07-04 22:24   ` John MacFarlane
     [not found]     ` <20150704222450.GC11787-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-07-05  1:02       ` Diego Algorta
     [not found]         ` <CAPfjgvJxjrE0E5=u1saMH8NPvRWf9Rb4PURmeiKFQ+xx7Zqyrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-05  4:06           ` John MacFarlane
     [not found]             ` <20150705040611.GA12677-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-07-05 16:24               ` John MacFarlane
     [not found]                 ` <20150705162410.GA14096-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-07-05 16:37                   ` fiddlosopher
     [not found]                     ` <ffc909e4-ed88-4852-a6a4-26f9a6f5162a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-07-05 17:24                       ` fiddlosopher
     [not found]                         ` <ad4bf09c-2d32-44b7-9e69-f3d45c74ae54-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-07-06 18:23                           ` Diego Algorta

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