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.

knoxgon
  • 1,070
  • 2
  • 15
  • 31
user12402799
  • 53
  • 1
  • 4
  • Does this answer your question? [Concatenate multiple Markdown files using Pandoc on Windows](https://stackoverflow.com/questions/49978926/concatenate-multiple-markdown-files-using-pandoc-on-windows) – knoxgon Mar 20 '20 at 11:39
  • 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. – user12402799 Mar 20 '20 at 13:18
  • Check my provided answer – knoxgon Mar 20 '20 at 13:49

2 Answers2

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

tarleb
  • 19,863
  • 4
  • 51
  • 80
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
knoxgon
  • 1,070
  • 2
  • 15
  • 31
  • 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) – user12402799 Mar 20 '20 at 15:37
  • 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. – knoxgon Mar 20 '20 at 18:25
  • 1
    I'll be OK with powershell. Thanks for your help Volkan. – user12402799 Mar 20 '20 at 18:57
  • @user12402799 Glad to help! – knoxgon Mar 20 '20 at 19:09