Converting Markdown to InDesign and Vice Versa
How to export and import InDesign documents into Markdown
The client wants to switch to a git-based documentation workflow using Markdown, but at the moment their documentation is based on InDesign and they will need to export Markdown to InDesign also in the future.
The goal should be to use Markdown on git as the source of the documentation by default. This will make version control possible and facilitate collaboration.
To achieve this, the first step should be to export all the InDesign files to Markdown, going through HTML.
- This page explains how to export InDesign to HTML
- Once the HTML files have been generated, converting them to markdown requires
Pandoc. Help the client install Pandoc following this guide
- There is also a web version of Pandoc
- Some markdown editors like Atom export HTML into markdown
- Assuming the HTML file that needs to be converted is named
file.htmland the Markdown file the client needs to generate should be called
file.md, the command to convert HTML to markdown is this:
pandoc -o file.md file.html
Once all the HTML files have been converted to markdown, the client can start updating their files directly in the git repository.
Markdown files can then be imported into InDesign going through HTML whenever the client feels they can consolidate one version into a PDF or print.
To export Markdown into HTML Pandoc can be used again, but also editors like Atom or ReText export markdown into HTML.
This time the command in pandoc will be:
pandoc -o file.html file.md( assuming the Markdown file that needs to be converted is named
file.mdand the HTML file the client needs to generate should be called
- Instead of the Python script included in this article to delete new lines in the HTML file (which doesn’t seem to work), we can send the client this script in bash. The script can be launched on a Linux machine (it should also work in a Mac terminal).
- Instructions for the client:
- Download the attached file to the folder where you have saved your HTML files. You can open the file with a text editor to check that all is ok. You can also find the script here
- allow the script to be executed, by running this command:
chmod 777 sed-clean-HTML.sh
- run this command on all your files: