How to concatenate multiple markdown files in a specific order in Windows
Asked Answered
U

2

5

I can easily do this in LINUX using an includes.txt file:

pandoc -s $(cat includes.txt) -o index.html

where includes.txt contains:

file1.md
file3.md
file2.md

The problem is that I now have to do the equivalent in Windows and cannot figure out how to concatenate the Markdown files in the order specified in the includes.txt file and then pass this to Pandoc.

Any help is appreciated.

Ultramicroscopic answered 20/3, 2020 at 9:14 Comment(3)
Does this answer your question? Concatenate multiple Markdown files using Pandoc on WindowsEnloe
Thanks, but that solution only appears to allow processing of 'all the files in a specified directory', and not the files in my 'includes.txt' file in the order they appear in that file (which is the important thing for me). My problem is just knowing how to translate my Linux command (which works just fine) into an equivalent Windows version.Ultramicroscopic
Check my provided answerEnloe
H
6

You could create a file defaults.yaml with the following content:

input-files:
  - file1.md
  - file3.md
  - file2.md

Then call pandoc with pandoc --defaults defaults.yaml ….

Hypoxia answered 22/3, 2020 at 21:47 Comment(0)
E
1

After a short research, I found that you can do the equivalent operation in Windows environment using Pandoc.

Download and install Pandoc using the following link. You should select pandoc-2.9.2-windows-x86_64.msi

Pandoc

After successful installation of Pandoc, open powershell to check if the program is successfully installed by running the following command.

pandoc --version

Now, running the provided command from your original post will work in Windows environment.

pandoc -s $(cat includes.txt) -o index.html
Enloe answered 20/3, 2020 at 13:47 Comment(4)
OK - thank you. Your solution works with powershell, but not with cmd.exe (which is what I had been using). When I try with cmd.exe, I get this error message: pandoc: $(cat: openBinaryFile: does not exist (No such file or directory)Ultramicroscopic
Will powershell suffice or is cmd a mandatory? After another research with self tests, I can confirm that cmd.exe is a bit problematic towards pandoc. Powershell works as intended.Enloe
I'll be OK with powershell. Thanks for your help Volkan.Ultramicroscopic
@Ultramicroscopic Glad to help!Enloe

© 2022 - 2024 — McMap. All rights reserved.