git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: Rewrote some inline parsing code for clarity.

(It seems clearer to put the whitespace parsing in the grouped parser. This also uses stateLastStrPos to determine when the border is adjacent to an alphanumeric.)

commit10644607e35369ec3b19b5d02fbe9b936d0ecb85 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 6 May 2014, 22:13 (12 years ago) parente7b4294
1 file changed+8−12
src/Text/Pandoc/Readers/Textile.hs+8−12
src/Text/Pandoc/Readers/Textile.hs+8−12
@@ -596,32 +596,28 @@ ungroupedSimpleInline :: Parser [Char] ParserState t -- ^ surrounding
596596ungroupedSimpleInline border construct = try $ do
597597 st <- getState
598598 pos <- getPosition
599− isWhitespace <- option False (whitespace >> return True)
600− guard $ (stateQuoteContext st /= NoQuote)
601− || (sourceColumn pos == 1)
602− || isWhitespace
599+ let afterString = stateLastStrPos st == Just pos
600+ guard $ not afterString
603601 border *> notFollowedBy (oneOf " \t\n\r")
604602 attr <- attributes
605603 body <- trimInlines . mconcat <$>
606604 withQuoteContext InSingleQuote
607605 (manyTill inline (try border <* notFollowedBy alphaNum))
608− let result = construct $
606+ return $ construct $
609607 if attr == nullAttr
610608 then body
611609 else B.spanWith attr body
612− return $ if isWhitespace
613− then B.space <> result
614− else result
615610
616611groupedSimpleInline :: Parser [Char] ParserState t
617612 -> (Inlines -> Inlines)
618613 -> Parser [Char] ParserState Inlines
619614groupedSimpleInline border construct = try $ do
620615 char '['
621− withQuoteContext InSingleQuote (simpleInline border construct) >>~ char ']'
622−
623−
624−
616+ sp1 <- option mempty $ B.space <$ whitespace
617+ result <- withQuoteContext InSingleQuote (simpleInline border construct)
618+ sp2 <- option mempty $ B.space <$ whitespace
619+ char ']'
620+ return $ sp1 <> result <> sp2
625621
626622-- | Create a singleton list
627623singleton :: a -> [a]