ICML writer: Better handling of raw blocks and inlines.
Previously these were always escaped and printed verbatim. Now they are ignored unless the format is "icml", in which case they are passed through unescaped. Closes #1951.
This commit is contained in:
parent
e8cd53d1c9
commit
3480189e8e
2 changed files with 7 additions and 136 deletions
|
@ -70,7 +70,6 @@ linkName = "Link"
|
|||
-- block element names (appear in InDesign's paragraph styles pane)
|
||||
paragraphName :: String
|
||||
codeBlockName :: String
|
||||
rawBlockName :: String
|
||||
blockQuoteName :: String
|
||||
orderedListName :: String
|
||||
bulletListName :: String
|
||||
|
@ -93,7 +92,6 @@ subListParName :: String
|
|||
footnoteName :: String
|
||||
paragraphName = "Paragraph"
|
||||
codeBlockName = "CodeBlock"
|
||||
rawBlockName = "Rawblock"
|
||||
blockQuoteName = "Blockquote"
|
||||
orderedListName = "NumList"
|
||||
bulletListName = "BulList"
|
||||
|
@ -278,7 +276,9 @@ blockToICML :: WriterOptions -> Style -> Block -> WS Doc
|
|||
blockToICML opts style (Plain lst) = parStyle opts style lst
|
||||
blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
|
||||
blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
|
||||
blockToICML opts style (RawBlock _ str) = parStyle opts (rawBlockName:style) $ [Str str]
|
||||
blockToICML _ _ (RawBlock f str)
|
||||
| f == Format "icml" = return $ text str
|
||||
| otherwise = return empty
|
||||
blockToICML opts style (BlockQuote blocks) = blocksToICML opts (blockQuoteName:style) blocks
|
||||
blockToICML opts style (OrderedList attribs lst) = listItemsToICML opts orderedListName style (Just attribs) lst
|
||||
blockToICML opts style (BulletList lst) = listItemsToICML opts bulletListName style Nothing lst
|
||||
|
@ -404,7 +404,9 @@ inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escap
|
|||
inlineToICML _ style Space = charStyle style space
|
||||
inlineToICML _ style LineBreak = charStyle style $ text lineSeparator
|
||||
inlineToICML _ style (Math _ str) = charStyle style $ text $ escapeStringForXML str --InDesign doesn't really do math
|
||||
inlineToICML _ style (RawInline _ str) = charStyle style $ text $ escapeStringForXML str
|
||||
inlineToICML _ _ (RawInline f str)
|
||||
| f == Format "icml" = return $ text str
|
||||
| otherwise = return empty
|
||||
inlineToICML opts style (Link lst (url, title)) = do
|
||||
content <- inlinesToICML opts (linkName:style) lst
|
||||
state $ \st ->
|
||||
|
|
|
@ -410,11 +410,6 @@
|
|||
<Properties>
|
||||
<BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
|
||||
</Properties>
|
||||
</ParagraphStyle>
|
||||
<ParagraphStyle Self="ParagraphStyle/Rawblock" Name="Rawblock" LeftIndent="0">
|
||||
<Properties>
|
||||
<BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
|
||||
</Properties>
|
||||
</ParagraphStyle>
|
||||
</RootParagraphStyleGroup>
|
||||
<RootTableStyleGroup Self="pandoc_table_styles">
|
||||
|
@ -1389,21 +1384,6 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>Interpreted markdown in a table:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><table></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><tr></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><td></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>This is </Content>
|
||||
|
@ -1412,16 +1392,6 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>emphasized</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content></td></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><td></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>And this is </Content>
|
||||
|
@ -1430,26 +1400,6 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>strong</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content></td></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content></tr></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content></table></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Here’s a simple block:</Content>
|
||||
|
@ -1497,31 +1447,11 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>This should just be an HTML comment:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><!-- Comment --></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Multiline:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><!--
|
||||
Blah
|
||||
Blah
|
||||
--></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><!--
|
||||
This is another comment.
|
||||
--></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Code block:</Content>
|
||||
|
@ -1537,11 +1467,6 @@ Blah
|
|||
<Content>Just plain comment, with trailing spaces on the line:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><!-- foo --></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Code:</Content>
|
||||
|
@ -1557,51 +1482,6 @@ Blah
|
|||
<Content>Hr’s:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr class="foo" id="bar" /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr class="foo" id="bar" /></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content><hr class="foo" id="bar"></Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Inline Markup</Content>
|
||||
|
@ -1980,9 +1860,7 @@ Blah
|
|||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>\cite[22-23]{smith.1899}</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
<Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
|
@ -2097,15 +1975,6 @@ Blah
|
|||
<Content>Here’s a LaTeX table:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>\begin{tabular}{|l|l|}\hline
|
||||
Animal & Number \\ \hline
|
||||
Dog & 2 \\
|
||||
Cat & 1 \\ \hline
|
||||
\end{tabular}</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Special Characters</Content>
|
||||
|
|
Loading…
Reference in a new issue