Hello,

My pre-processing lua filter might give a hint for you.
https://github.com/pandocker/pandocker-lua-filters/blob/master/lua/preprocess.lua
(I know this filter implement is not great. PR welcome btw )

1. make another md file ("base.md" for example) to include files by your order like:

``` markdown
# #include "0-01-reagle-koerner.md"
# #include "1-00-hindsight.md"
# #include "1-01-reagle.md"
# #include "1-02-benjakob-harrison.md"
# #include "1-03-hill-shaw.md"
```

2. let pandoc process with base.md and the filter
pandoc -t docx --lua-filter=preprocess.lua base.md -o out.docx

3. the out.docx is equivalent to concatenated files by your order




2019年9月25日(水) 17:10 Agustín Martín <agusmba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> In addition to adding page breaks between the chapters, I'd like to have the title (first level-1 heading, in this case) prefixed with an chapter number taken from the file name. I want to do this dynamically, as I might rename/resort/reorganize the files based on their names.

I'm not sure if you're artificially complicating matters. Both things can be achieved simply by modifying your reference-doc heading styles, having first level heading include a pagebreak before, and being numbered. Then you can put any name to the files (numbers if you like for sorting), and all your chapters will be sensibly numbered (independently of what the name of the original file was).



On Monday, September 16, 2019 at 10:15:49 PM UTC+2, Joseph wrote:

On 9/5/19 4:48 PM, Joseph Reagle wrote:
> ```
>  for f in *-*-*.md; do cat $f page-break.md; done > test.md
> ```

In addition to adding page breaks between the chapters, I'd like to have the title (first level-1 heading, in this case) prefixed with an chapter number taken from the file name. I want to do this dynamically, as I might rename/resort/reorganize the files based on their names.

So, for example, `1-01-reagle.md` is the first chapter in the first section, and could have '1.' prefixed to its first heading. In looking at filters, especially panflute, all the examples are of stand-alone filters that are stateless between invocations...

```
0-01-reagle-koerner.md                        
1-00-hindsight.md                            
1-01-reagle.md                                    
1-02-benjakob-harrison.md                
1-03-hill-shaw.md
```

Any suggestions?

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d4057f17-ab65-4bb4-afb4-7ec97ab3cb22%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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAPBn7noaBRW%2Bg%2B_Opvb28MPrW1w1rnLC1LSyrU8xSES3%3Dt6OYg%40mail.gmail.com.