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.