IDML Reference / Stories & text
Your first story
Build up an IDML story in three steps — one line of text, a second paragraph with the <Br/> mark, then a change of formatting with a new range.
Reviewed against engine v0.71.6
A story is text plus the runs that format it. Three small steps show the whole model: one line, a second paragraph, a change of formatting.
In short The smallest story is a Story holding one ParagraphStyleRange, holding
one CharacterStyleRange, holding one Content element. To add a paragraph you do not
add an element: you end the first paragraph with a <Br/> mark and keep writing. To
change formatting you split the run where the formatting changes. Each step below is a
complete package, checked by opening it in InDesign and rendered live on this page.
Step 1: one line of text
Here is the complete story from the smallest valid package. Read it from the inside out:
Content holds the characters; the CharacterStyleRange around it says how they are
formatted (here, the default character style); the ParagraphStyleRange says how the
paragraph is formatted (the default paragraph style); and the Story carries the Self
id that a text frame points at to display the text.
The whole story: one paragraph run, one character run, one line of text.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="20.0">
<Story Self="ustory">
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Hello, paged media.</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
</Story>
</idPkg:Story>
Step 2: a second paragraph
To start a second paragraph, end the first one with <Br/>, the paragraph mark, and add
the next text. Both paragraphs share the same formatting, so they stay in the same runs.
The last paragraph of a story never ends with a mark.
One run, two paragraphs: the <Br/> on line 7 is where the first one ends.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="20.0">
<Story Self="ustory">
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>The first paragraph stands on its own.</Content>
<Br/>
<Content>The second paragraph follows it.</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
</Story>
</idPkg:Story>
Step 3: a change of formatting
Formatting changes split runs. Here both runs apply the same character style, Emphasis,
and the second overrides its size on the range itself, so the text is split into two
CharacterStyleRange elements at the point where the size changes. A change of
paragraph formatting would split the ParagraphStyleRange the same way, at a
paragraph's end.
The same style twice; the second run overrides PointSize, so the text splits into
two character runs.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="20.0">
<Story Self="ustory">
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Emphasis">
<Content>Emphasis as defined, </Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Emphasis" PointSize="24">
<Content>then PointSize overridden to 24 on the range.</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
</Story>
</idPkg:Story>
That is the whole model: text, with paragraph marks in it, under two layers of non-overlapping runs. Story structure is the full reference, and the paragraph model explains why IDML works this way.
Frequently asked questions
What is the minimum a story needs to show a line of text?
A Story wrapping one ParagraphStyleRange, wrapping one CharacterStyleRange,
wrapping one Content element with the text, as in step 1.
How do I add a second paragraph?
End the first one with <Br/> and continue the text. You only need a new
ParagraphStyleRange if the new paragraph is formatted differently.
When does a new CharacterStyleRange start?
Wherever any character attribute changes: the style, or a local override such as the
size, font or colour.
Stories & text
In IDML, a document's text lives in stories — streams of characters under runs of shared formatting, shown by frames that can thread across pages.
Story structure
How an IDML story is built — style runs (ParagraphStyleRange, CharacterStyleRange), Content, and the characters that end paragraphs, break lines and tab.