mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
3a5f7ecee1
Word-95-style numbered and bulleted lists are encoded with a
`{\pntext ...}` auto-number destination at the start of each list
paragraph plus a `{\*\pn ...}` destination describing the numbering,
rather than the modern `\listtext`/`\listtable` mechanism. Two problems:
1. The `\pntext` marker text ("1.", "·", etc.) was captured as the
paragraph's first text run, which sits before the paragraph's
`\ls`/`\ilvl`, so emitBlocks (which reads list properties from the first
run) misclassified the paragraph as an ordinary paragraph. The first
item of each list therefore came out as a stray paragraph.
2. The numbering style was ignored, so numbered lists defaulted to
bullets.
Treat `\pntext` like `\listtext`: drop its visible marker text and flag the
start of a new list item. Parse the `{\*\pn ...}` destination
(`\pnlvlbody`/`\pnlvlblt`, `\pndec`, `\pnucltr`, `\pnlcltr`,
`\pnucrm`, `\pnlcrm`, `\pnstart`, and the `\ls`/`\ilvl` keys it
carries) into the list override table so numbered lists are
emitted as ordered lists with the right number style.
`\pn` is a paragraph property that remains in effect until reset
by `\pard`, auto-numbering every paragraph in scope. Track
this (`sPnActive`) so each paragraph becomes its own list item,
rather than merging markerless continuation paragraphs as is done
for modern `\listtext` lists.
Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.2 KiB
Haskell
44 lines
1.2 KiB
Haskell
{- |
|
|
Module : Tests.Readers.RTF
|
|
Copyright : © 2021-2024 John MacFarlane
|
|
License : GNU GPL, version 2 or above
|
|
|
|
Maintainer : jgm@berkeley.edu
|
|
Stability : alpha
|
|
Portability : portable
|
|
|
|
Tests for the RTF reader.
|
|
-}
|
|
module Tests.Readers.RTF (tests) where
|
|
|
|
import Test.Tasty
|
|
import Tests.Helpers
|
|
import Text.Pandoc
|
|
import System.FilePath (replaceExtension, (</>), (<.>))
|
|
|
|
rtfTest :: TestName -> TestTree
|
|
rtfTest name = testGolden name native path
|
|
(\t -> runIOorExplode
|
|
(readRTF def t >>=
|
|
writeNative def{ writerTemplate = Just mempty }))
|
|
where native = replaceExtension path ".native"
|
|
path = "rtf" </> name <.> "rtf"
|
|
|
|
|
|
tests :: [TestTree]
|
|
tests = map rtfTest [ "footnote"
|
|
, "accent"
|
|
, "unicode"
|
|
, "image"
|
|
, "link"
|
|
, "heading"
|
|
, "formatting"
|
|
, "list_simple"
|
|
, "list_complex"
|
|
, "list_multiparagraph"
|
|
, "list_legacy"
|
|
, "bookmark"
|
|
, "table_simple"
|
|
, "table_error_codes"
|
|
]
|