bitandblack / markdown-idml-converter
Convert Markdown into (parts of) Adobe InDesign Markup Language Files (IDML).
Fund package maintenance!
Buymeacoffee
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bitandblack/markdown-idml-converter
Requires
- php: >=8.2
- bitandblack/idml-creator: ^5.0
Requires (Dev)
- ext-dom: *
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
- symfony/var-dumper: ^8.0
- symplify/easy-coding-standard: ^13.0
README
Bit&Black Markdown-IDML-Converter
Convert Markdown into (parts of) Adobe InDesign Markup Language Files (IDML).
Installation
This library is written in PHP and made for the use with Composer. Be sure to have both of them installed on your system.
As this library requires the IDML Creator — which requires a licence — be sure to get one at first. If not already part of your project, add the Composer credentials. (This is explained for example here.)
Add the library then to your project by running $ composer require bitandblack/markdown-idml-converter.
Usage
Converting Markdown into IDML Formatted Text
This library can convert a few Markdown formats into Paragraph and Character Styles. It can handle:
- The base "copy" paragraph
- Headlines from hierarchy 1 to 6
- An italic formatting
- A bold formatting
Therefore, the first step is to create an array with the styles, that should be used:
<?php use BitAndBlack\IdmlCreator\Content\Style\CharacterStyle; use BitAndBlack\IdmlCreator\Content\Style\ParagraphStyle; use BitAndBlack\MarkdownIdmlConverter\MarkdownToStyles; $formats = [ MarkdownToStyles::PARAGRAPH_STYLE_BODY => new ParagraphStyle('Body'), MarkdownToStyles::CHARACTER_STYLE_ITALIC => new CharacterStyle('Italic'), MarkdownToStyles::CHARACTER_STYLE_BOLD => new CharacterStyle('Bold'), ];
Second, the MarkdownToStyles class can be initialised with those styles and text can be converted:
<?php use BitAndBlack\MarkdownIdmlConverter\MarkdownToStyles; $markdownToStyles = new MarkdownToStyles($formats); $paragraphStyleRange = $markdownToStyles->convert($markdownFormattedText);
The result is a IDML ParagraphStyleRange, that can be handled using the IDML Creator.
Other Tools
Bit&Black offers some more tools to handle IDML files:
- The IDML-Creator library that allows creating IDML content natively in PHP in an object-oriented way. (A demo is available here.)
- The IDML-Writer library that can write IDML content into a valid IDML file.
- The IDML-Validator library that allows validating IDML files against the official schema from Adobe.
- The IDML-JSON-Converter library that allows converting Adobe InDesign Markup Language Files (IDML) into JSON and JSON into IDML.
Feel free to visit www.idml.dev for more information!
Help
If you have any questions feel free to contact us under hello@bitandblack.com.
Further information about Bit&Black can be found under www.bitandblack.com.