aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-11-08 15:07:05 +0100
committerJohn MacFarlane <[email protected]>2025-11-08 15:07:05 +0100
commitd13b0bfe8aaf024edbff8525aa3cb2fdb451b429 (patch)
tree362fbf6b980c5c4e3d5b44a8442e97df32b324d0
parentf1152c18111889a1ddd376420a717ad9f9b484b0 (diff)
ICML writer: base FirstParagraph styles on corresponding...issue_11268
Paragraph styles. This should ensure that existing documents still work with the FirstParagraph style, without the need to define new styles.
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs7
-rw-r--r--test/command/5541-localLink.md2
-rw-r--r--test/command/5541-urlLink.md2
-rw-r--r--test/command/6675.md2
-rw-r--r--test/writer.icml16
5 files changed, 17 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
index d5a52ec90..58d48a5e3 100644
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -37,6 +37,7 @@ import Text.Pandoc.Templates (renderTemplate)
import Text.Pandoc.Writers.Math (texMathToInlines)
import Text.Pandoc.Writers.Shared
import Text.Pandoc.XML
+import qualified Data.Text as T
type Style = [Text]
type Hyperlink = [(Int, Text)]
@@ -238,7 +239,11 @@ parStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ blockStyles st
font = if codeBlockName `Text.isInfixOf` s
then monospacedFont
else empty
- basedOn = inTags False "BasedOn" [("type", "object")] (text "$ID/NormalParagraphStyle") $$ font
+ baseStyle = if firstParagraphName `T.isSuffixOf` s
+ then T.replace firstParagraphName paragraphName s
+ else "$ID/NormalParagraphStyle"
+ basedOn = inTags False "BasedOn" [("type", "object")]
+ (literal baseStyle) $$ font
tabList = if isBulletList
then inTags True "TabList" [("type","list")] $ inTags True "ListItem" [("type","record")]
$ vcat [
diff --git a/test/command/5541-localLink.md b/test/command/5541-localLink.md
index 9579dc00e..9214895a0 100644
--- a/test/command/5541-localLink.md
+++ b/test/command/5541-localLink.md
@@ -42,7 +42,7 @@ if you can read this text, [and it's linked]{#spanner} - all good!
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/FirstParagraph" Name="FirstParagraph" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Header1" Name="Header1" LeftIndent="0" PointSize="36">
diff --git a/test/command/5541-urlLink.md b/test/command/5541-urlLink.md
index 00fa750f5..35cd196a7 100644
--- a/test/command/5541-urlLink.md
+++ b/test/command/5541-urlLink.md
@@ -38,7 +38,7 @@ some more text that [links to](https://www.pandoc.org) Pandoc.
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/FirstParagraph" Name="FirstParagraph" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Header1" Name="Header1" LeftIndent="0" PointSize="36">
diff --git a/test/command/6675.md b/test/command/6675.md
index 6d4d2207b..18bb5ad9a 100644
--- a/test/command/6675.md
+++ b/test/command/6675.md
@@ -40,7 +40,7 @@ and some text that [links to](#header-1) the first header
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/FirstParagraph" Name="FirstParagraph" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Header1" Name="Header1" LeftIndent="0" PointSize="36">
diff --git a/test/writer.icml b/test/writer.icml
index d6955b131..e62e65d0b 100644
--- a/test/writer.icml
+++ b/test/writer.icml
@@ -87,7 +87,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Blockquote &gt; Blockquote &gt; FirstParagraph" Name="Blockquote &gt; Blockquote &gt; FirstParagraph" LeftIndent="30">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Blockquote > Blockquote > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph" Name="Blockquote &gt; Blockquote &gt; Paragraph" LeftIndent="30">
@@ -103,7 +103,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Blockquote &gt; FirstParagraph" Name="Blockquote &gt; FirstParagraph" LeftIndent="10">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Blockquote > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Blockquote &gt; NumList" Name="Blockquote &gt; NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
@@ -214,7 +214,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/BulList &gt; first &gt; FirstParagraph" Name="BulList &gt; first &gt; FirstParagraph" BulletsAndNumberingListType="BulletList" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">BulList > first > Paragraph</BasedOn>
<TabList type="list">
<ListItem type="record">
<Alignment type="enumeration">LeftAlign</Alignment>
@@ -256,7 +256,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/DefListDef &gt; Blockquote &gt; FirstParagraph" Name="DefListDef &gt; Blockquote &gt; FirstParagraph" LeftIndent="30">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">DefListDef > Blockquote > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/DefListDef &gt; CodeBlock" Name="DefListDef &gt; CodeBlock" LeftIndent="10">
@@ -292,7 +292,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/FirstParagraph" Name="FirstParagraph" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Footnote &gt; CodeBlock" Name="Footnote &gt; CodeBlock" LeftIndent="0">
@@ -303,7 +303,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Footnote &gt; FirstParagraph" Name="Footnote &gt; FirstParagraph" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">Footnote > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/Footnote &gt; Paragraph" Name="Footnote &gt; Paragraph" LeftIndent="0">
@@ -369,7 +369,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/NumList &gt; FirstParagraph" Name="NumList &gt; FirstParagraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">NumList > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-3 &gt; lowerAlpha" Name="NumList &gt; NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-3 &gt; lowerAlpha" NumberingExpression="^#.^t" NumberingLevel="4" BulletsAndNumberingListType="NumberedList" LeftIndent="30">
@@ -440,7 +440,7 @@
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; beginsWith-2 &gt; FirstParagraph" Name="NumList &gt; first &gt; beginsWith-2 &gt; FirstParagraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
<Properties>
- <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <BasedOn type="object">NumList > first > beginsWith-2 > Paragraph</BasedOn>
</Properties>
</ParagraphStyle>
<ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; upperAlpha" Name="NumList &gt; first &gt; upperAlpha" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">