Skip to content

Commit

Permalink
Pandoc writer: fix spacing inside EDelimited.
Browse files Browse the repository at this point in the history
Previously spaces around binary operators were omitted when
they occurred inside parens or brackets.  See #234.
  • Loading branch information
jgm committed Mar 6, 2024
1 parent b9fa53a commit f8d16c2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Text/TeXMath/Writers/Pandoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ expToInlines tt (EIdentifier s) = Just $ renderStr tt s
expToInlines tt (EMathOperator s) = Just $ renderStr tt s
expToInlines tt (ESymbol _ s) = Just $ renderStr tt s
expToInlines tt (EDelimited start end xs) = do
xs' <- mapM (either (return . renderStr tt) (expToInlines tt)) xs
return $ renderStr tt start ++ concat xs' ++ renderStr tt end
xs' <- expsToInlines tt $ map (either (ESymbol Ord) id) xs
return $ renderStr tt start ++ xs' ++ renderStr tt end
expToInlines tt (EGrouped xs) = expsToInlines tt xs
expToInlines _ (EStyled tt' xs) = expsToInlines (Just tt') xs
expToInlines _ (ESpace n) = Just [Str $ getSpaceChars n]
Expand Down
24 changes: 24 additions & 0 deletions test/regression/234.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<<< native
[ ENumber "2"
, ESymbol Bin "+"
, EDelimited
"("
")"
[ Right (ENumber "2")
, Right (ESymbol Bin "+")
, Right (ENumber "3")
]
]
>>> pandoc
[ Str "2"
, Str "\8197"
, Str "+"
, Str "\8197"
, Str "("
, Str "2"
, Str "\8197"
, Str "+"
, Str "\8197"
, Str "3"
, Str ")"
]

0 comments on commit f8d16c2

Please sign in to comment.