ICML writer: better handling of math.
Instead of just printing the raw tex, we now try to fake it with unicode characters.
This commit is contained in:
parent
46ff0e988a
commit
f096f032f0
2 changed files with 62 additions and 10 deletions
|
@ -16,6 +16,7 @@ into InDesign with File -> Place.
|
|||
module Text.Pandoc.Writers.ICML (writeICML) where
|
||||
import Text.Pandoc.Definition
|
||||
import Text.Pandoc.XML
|
||||
import Text.Pandoc.Readers.TeXMath (texMathToInlines)
|
||||
import Text.Pandoc.Writers.Shared
|
||||
import Text.Pandoc.Shared (splitBy)
|
||||
import Text.Pandoc.Options
|
||||
|
@ -410,7 +411,8 @@ inlineToICML opts style (Cite _ lst) = inlinesToICML opts style lst
|
|||
inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str
|
||||
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 opts style (Math mt str) =
|
||||
cat <$> mapM (inlineToICML opts style) (texMathToInlines mt str)
|
||||
inlineToICML _ _ (RawInline f str)
|
||||
| f == Format "icml" = return $ text str
|
||||
| otherwise = return empty
|
||||
|
|
|
@ -1864,17 +1864,49 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>2+2=4</Content>
|
||||
<Content>2</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>+</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>2</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>=</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>4</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>x \in y</Content>
|
||||
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>x</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>∈</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>y</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>\alpha \wedge \omega</Content>
|
||||
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>α</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>∧</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>ω</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
|
@ -1883,7 +1915,7 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>p</Content>
|
||||
</CharacterStyleRange>
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
|
@ -1895,15 +1927,33 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>Here’s some display math: </Content>
|
||||
</CharacterStyleRange>
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</Content>
|
||||
<Content>$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>Here’s one that has a line break in it: </Content>
|
||||
</CharacterStyleRange>
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>\alpha + \omega \times x^2</Content>
|
||||
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>α</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>+</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>ω</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>×</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content> </Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
|
||||
<Content>x</Content>
|
||||
</CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript">
|
||||
<Content>2</Content>
|
||||
</CharacterStyleRange>
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>.</Content>
|
||||
|
|
Loading…
Reference in a new issue