Convert IDML files to DocBook.
Project description
idml2docbook
This Python package converts IDML (InDesign Markup Language) files to Docbook 5.1.
More importantly, because DocBook is supported by Pandoc, this tool effectively enables IDML to be converted into dozens of other formats (Markdown, DOCX, EPUB, ODT, AsciiDoc, etc.). In practice, idml2docbook acts as a custom reader of IDML files for Pandoc. It is a bridge between InDesign and the Pandoc ecosystem.
flowchart LR
subgraph S1["idml2docbook"]
IDML[IDML] --> DOCBOOK[DocBook]
end
subgraph S2["Pandoc"]
DOCBOOK --> MD[Markdown]
DOCBOOK --> DOCX[DOCX]
DOCBOOK --> ADOC[AsciiDoc]
DOCBOOK --> ODT[ODT]
DOCBOOK --> EPUB[EPUB]
DOCBOOK --> ETC[etc.]
end
Installation
First, create a virtual environment.
Then, you can install and download this package using pip:
pip install idml2docbook
The package is now installed, but the environment still needs to be configured. This converter requires external dependencies because it is basically a wrapper around idml2xml-frontend that takes its Hub XML output and converts it to Docbook 5.1. To make it all work, the following is required:
- Python >= 3.x
- Java >= 1.7
- bash >= 5.x (by default, on macOS, the installed version is 3.2 — a more recent version can be installed with brew)
- git (needed to install idml2xml-frontend)
- idml2xml-frontend
The following command helps you check if you have those dependencies installed. It also installs idml2xml-frontend and generates a sample .env if none are to be found in your folder:
idml2docbook-install-dependencies
If you already have a .env file in your project, you will need to manually add it the path to idml2xml-frontend:
IDML2HUBXML_SCRIPT_FOLDER="/path/to/idml2xml-frontend"
For large IDML files, it may be necessary to increase the Java heap size, for example to 2048m or 4096m.
Usage
Command-line
Convert an IDML file:
idml2docbook file.idml
Options are also available. They are as well documented in the command-line tool (see the help with -h/--help).
-
-x,--idml2hubxml-file
Treats the input file as a Hub XML file.
Useful for saving processing time ifidml2xml-frontendhas already been run on the source IDML file. -
-o,--output <file>
Name to assign to the output file.
By default, output is sent to standard output (stdout). -
-t,--typography
Applies French typographic refinements.
(thin spaces, non-breaking spaces, etc.). -
-l,--thin-spaces
Use only thin spaces for typography refinement.
Should be used together with--typography. -
-b,--linebreaks
Do not replace<br>tags with spaces. -
-f,--media <path>
Path to the folder containing media files.
Default:Links. -
-r,--raster <extension>
Extension to use when replacing that of raster images.
Example:jpg. -
-v,--vector <extension>
Extension to use when replacing that of vector images.
Example:svg. -
-i,--idml2hubxml-output <path>
Path to the output from Transpect’s idml2hubxml converter.
Default:idml2hubxml. -
-s,--idml2hubxml-script <path>
Path to the script of Transpect’s idml2xml-frontend converter. -
--version
Displays the version of idml2docbook and exits the program.
IDML custom reader for Pandoc
Simple command to use this package with Pandoc:
pandoc -f docbook -t markdown <(idml2docbook input.idml)
Though, it is possible to do crazy stuff as well 🤪
pandoc -f docbook \
-t markdown_phpextra \
--wrap=none \
-o output/output.md \
<(idml2docbook input.idml \
--typography \
--thin-spaces \
--raster jpg \
--vector svg \
--media images)
InDesign paragraph and character styles are converted into DocBook as role attributes.
Pandoc supports role attributes in the Docbook reader in versions 3.9 (February 2026) and higher.
In order to convert role attributes into Pandoc classes, the roles-to-classes.lua filter can be used:
pandoc -f docbook -t markdown --lua-filter=roles-to-classes.lua <(idml2docbook input.idml)
Python script
Sample script to use the API:
from idml2docbook.core import idml2docbook
file = "input.idml"
# Options are optional!
options = {
'typography': True,
'thin_spaces': True,
'linebreaks': True,
'ignore_overrides': True,
'raster': "jpg",
'vector': "svg",
'media': "images"
}
output = idml2docbook(file, **options)
print(output)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idml2docbook-1.1.6.tar.gz.
File metadata
- Download URL: idml2docbook-1.1.6.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca0ede74cf1a9091a001e00188c7e155e9d74d0bbed59228bb207c96800b965
|
|
| MD5 |
34a99e67b680d7f9f1976169b737b021
|
|
| BLAKE2b-256 |
224fcdea4c2b78698775568dd8da3771ee516cf4bd098e0d0ed047266ad76d8c
|
Provenance
The following attestation bundles were made for idml2docbook-1.1.6.tar.gz:
Publisher:
publish.yml on yanntrividic/idml2docbook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idml2docbook-1.1.6.tar.gz -
Subject digest:
cca0ede74cf1a9091a001e00188c7e155e9d74d0bbed59228bb207c96800b965 - Sigstore transparency entry: 952592829
- Sigstore integration time:
-
Permalink:
yanntrividic/idml2docbook@d1703ce23810251cfa6efbb146ab67b1150cf3ca -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yanntrividic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d1703ce23810251cfa6efbb146ab67b1150cf3ca -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file idml2docbook-1.1.6-py3-none-any.whl.
File metadata
- Download URL: idml2docbook-1.1.6-py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f5159d2cf6789082dfdc0e12ba8c534ec2f3893da2c01d995cd8a59d398b772
|
|
| MD5 |
c1880231e6dd82e2570606f4c9592dc0
|
|
| BLAKE2b-256 |
353b14fe98ca053c0906afa6c39098edc01525d9f17821948c4a6066cfe831bb
|
Provenance
The following attestation bundles were made for idml2docbook-1.1.6-py3-none-any.whl:
Publisher:
publish.yml on yanntrividic/idml2docbook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idml2docbook-1.1.6-py3-none-any.whl -
Subject digest:
5f5159d2cf6789082dfdc0e12ba8c534ec2f3893da2c01d995cd8a59d398b772 - Sigstore transparency entry: 952592835
- Sigstore integration time:
-
Permalink:
yanntrividic/idml2docbook@d1703ce23810251cfa6efbb146ab67b1150cf3ca -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yanntrividic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d1703ce23810251cfa6efbb146ab67b1150cf3ca -
Trigger Event:
workflow_dispatch
-
Statement type: