Skip to content

Commit a533fa4

Browse files
jgmclaude
andcommitted
ODT reader: rewrite in monadic style instead of arrows.
The ODT reader was written in an idiosyncratic arrows-based style, using a custom ArrowState arrow and dozens of special combinators. Replace this with an ordinary monad: type XMLConverter nsID extraState = ExceptT () (State (XMLConverterState nsID extraState)) This preserves the original semantics (state changes persist through failure; recovery via Alternative's <|>) while allowing all readers to be written in plain do/applicative notation. - Rewrite Generic/XMLConverter.hs around the new monad; replace the parent-element stack with a single currentElement field, and make matchContent matchers simple (namespace, name, reader) triples whose results are mconcat'd in document order. - Port StyleReader.hs and ContentReader.hs to monadic style. - constructList now runs its child reader once instead of twice. - Delete Arrows/State.hs, Arrows/Utils.hs, and Base.hs; trim Generic/Fallible.hs and Generic/Utils.hs to what is still used. Net -994 lines. No changes to test output. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1791dd8 commit a533fa4

10 files changed

Lines changed: 777 additions & 1771 deletions

File tree

pandoc.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ library
771771
Text.Pandoc.Readers.Mdoc.Standards,
772772
Text.Pandoc.Readers.Typst.Parsing,
773773
Text.Pandoc.Readers.Typst.Math,
774-
Text.Pandoc.Readers.ODT.Base,
775774
Text.Pandoc.Readers.ODT.Namespaces,
776775
Text.Pandoc.Readers.ODT.StyleReader,
777776
Text.Pandoc.Readers.ODT.ContentReader,
@@ -780,8 +779,6 @@ library
780779
Text.Pandoc.Readers.ODT.Generic.Utils,
781780
Text.Pandoc.Readers.ODT.Generic.Namespaces,
782781
Text.Pandoc.Readers.ODT.Generic.XMLConverter,
783-
Text.Pandoc.Readers.ODT.Arrows.State,
784-
Text.Pandoc.Readers.ODT.Arrows.Utils,
785782
Text.Pandoc.Readers.Org.BlockStarts,
786783
Text.Pandoc.Readers.Org.Blocks,
787784
Text.Pandoc.Readers.Org.DocumentTree,

src/Text/Pandoc/Readers/ODT.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ archiveToODT archive = do
103103
let media = filteredFilesFromArchive archive filePathIsODTMedia
104104
let startState = readerState styles media
105105
either (\_ -> Left $ PandocParseError "Could not convert opendocument") Right
106-
(runConverter' read_body startState contentElem)
106+
(runConverter read_body startState contentElem)
107107

108108

109109
--

src/Text/Pandoc/Readers/ODT/Arrows/State.hs

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)