git.iko.soy/typeable/pandoc
on master help sign in
RST reader: Refactored directive parser.

We now also hander container, compound, epigraph, rubric, highligts, pull-quote.

commit3a589b7bca6282e6dd914ce9ab73ed2d52f747ab authorJohn MacFarlane <jgm@berkeley.edu> dateSat 29 Sep 2012, 16:22 (14 years ago) parent28fe9c1
1 file changed+105−83
src/Text/Pandoc/Readers/RST.hs+105−83
src/Text/Pandoc/Readers/RST.hs+105−83
@@ -52,6 +52,8 @@ readRST :: ReaderOptions -- ^ Reader options
5252 -> Pandoc
5353readRST opts s = (readWith parseRST) def{ stateOptions = opts } (s ++ "\n\n")
5454
55+type RSTParser = Parser [Char] ParserState
56+
5557--
5658-- Constants and data structure definitions
5759---
@@ -95,7 +97,7 @@ titleTransform ((Header 1 head1):rest) |
9597 (promoteHeaders 1 rest, head1)
9698titleTransform blocks = (blocks, [])
9799
98−parseRST :: Parser [Char] ParserState Pandoc
100+parseRST :: RSTParser Pandoc
99101parseRST = do
100102 optional blanklines -- skip blank lines at beginning of file
101103 startPos <- getPosition
@@ -124,10 +126,10 @@ parseRST = do
124126-- parsing blocks
125127--
126128
127−parseBlocks :: Parser [Char] ParserState Blocks
129+parseBlocks :: RSTParser Blocks
128130parseBlocks = mconcat <$> manyTill block eof
129131
130−block :: Parser [Char] ParserState Blocks
132+block :: RSTParser Blocks
131133block = choice [ codeBlock
132134 , rawBlock
133135 , blockQuote
@@ -137,7 +139,7 @@ block = choice [ codeBlock
137139 , customCodeBlock
138140 , mathBlock
139141 , defaultRoleBlock
140− , unknownDirective
142+ , directive
141143 , header
142144 , hrule
143145 , lineBlock -- must go before definitionList
@@ -152,7 +154,7 @@ block = choice [ codeBlock
152154-- field list
153155--
154156
155−rawFieldListItem :: String -> Parser [Char] ParserState (String, String)
157+rawFieldListItem :: String -> RSTParser (String, String)
156158rawFieldListItem indent = try $ do
157159 string indent
158160 char ':'
@@ -165,7 +167,7 @@ rawFieldListItem indent = try $ do
165167 return (name, raw)
166168
167169fieldListItem :: String
168− -> Parser [Char] ParserState (Maybe (Inlines, [Blocks]))
170+ -> RSTParser (Maybe (Inlines, [Blocks]))
169171fieldListItem indent = try $ do
170172 (name, raw) <- rawFieldListItem indent
171173 let term = B.str name
@@ -192,7 +194,7 @@ extractContents [Plain auth] = auth
192194extractContents [Para auth] = auth
193195extractContents _ = []
194196
195−fieldList :: Parser [Char] ParserState Blocks
197+fieldList :: RSTParser Blocks
196198fieldList = try $ do
197199 indent <- lookAhead $ many spaceChar
198200 items <- many1 $ fieldListItem indent
@@ -204,7 +206,7 @@ fieldList = try $ do
204206-- line block
205207--
206208
207−lineBlockLine :: Parser [Char] ParserState Inlines
209+lineBlockLine :: RSTParser Inlines
208210lineBlockLine = try $ do
209211 char '|'
210212 char ' ' <|> lookAhead (char '\n')
@@ -215,7 +217,7 @@ lineBlockLine = try $ do
215217 then mconcat line
216218 else B.str white <> mconcat line
217219
218−lineBlock :: Parser [Char] ParserState Blocks
220+lineBlock :: RSTParser Blocks
219221lineBlock = try $ do
220222 lines' <- many1 lineBlockLine
221223 blanklines
@@ -226,7 +228,7 @@ lineBlock = try $ do
226228--
227229
228230-- note: paragraph can end in a :: starting a code block
229−para :: Parser [Char] ParserState Blocks
231+para :: RSTParser Blocks
230232para = try $ do
231233 result <- trimInlines . mconcat <$> many1 inline
232234 option (B.plain result) $ try $ do
@@ -239,20 +241,20 @@ para = try $ do
239241 <> codeblock
240242 _ -> return (B.para result)
241243
242−plain :: Parser [Char] ParserState Blocks
244+plain :: RSTParser Blocks
243245plain = B.plain . trimInlines . mconcat <$> many1 inline
244246
245247--
246248-- image block
247249--
248250
249−imageBlock :: Parser [Char] ParserState Blocks
251+imageBlock :: RSTParser Blocks
250252imageBlock = try $ do
251253 string ".. "
252254 res <- imageDef (B.str "image")
253255 return $ B.para res
254256
255−imageDef :: Inlines -> Parser [Char] ParserState Inlines
257+imageDef :: Inlines -> RSTParser Inlines
256258imageDef defaultAlt = try $ do
257259 string "image:: "
258260 src <- escapeURI . removeLeadingTrailingSpace <$> manyTill anyChar newline
@@ -271,11 +273,11 @@ imageDef defaultAlt = try $ do
271273-- header blocks
272274--
273275
274−header :: Parser [Char] ParserState Blocks
276+header :: RSTParser Blocks
275277header = doubleHeader <|> singleHeader <?> "header"
276278
277279-- a header with lines on top and bottom
278−doubleHeader :: Parser [Char] ParserState Blocks
280+doubleHeader :: RSTParser Blocks
279281doubleHeader = try $ do
280282 c <- oneOf underlineChars
281283 rest <- many (char c) -- the top line
@@ -300,7 +302,7 @@ doubleHeader = try $ do
300302 return $ B.header level txt
301303
302304-- a header with line on the bottom only
303−singleHeader :: Parser [Char] ParserState Blocks
305+singleHeader :: RSTParser Blocks
304306singleHeader = try $ do
305307 notFollowedBy' whitespace
306308 txt <- trimInlines . mconcat <$> many1 (do {notFollowedBy blankline; inline})
@@ -377,7 +379,7 @@ customCodeBlock = try $ do
377379 return $ B.codeBlockWith ("", ["sourceCode", language], [])
378380 $ stripTrailingNewlines result
379381
380−figureBlock :: Parser [Char] ParserState Blocks
382+figureBlock :: RSTParser Blocks
381383figureBlock = try $ do
382384 string ".. figure::"
383385 src <- escapeURI . removeLeadingTrailingSpace <$> manyTill anyChar newline
@@ -385,7 +387,7 @@ figureBlock = try $ do
385387 caption <- parseFromString extractCaption body
386388 return $ B.para $ B.image src "" caption
387389
388−extractCaption :: Parser [Char] ParserState Inlines
390+extractCaption :: RSTParser Inlines
389391extractCaption = try $ do
390392 manyTill anyLine blanklines
391393 trimInlines . mconcat <$> many inline
@@ -417,7 +419,7 @@ mathBlockMultiline = try $ do
417419 $ filter (not . null) $ splitBy null lns'
418420 return $ B.para $ mconcat $ map B.displayMath eqs
419421
420−lhsCodeBlock :: Parser [Char] ParserState Blocks
422+lhsCodeBlock :: RSTParser Blocks
421423lhsCodeBlock = try $ do
422424 guardEnabled Ext_literate_haskell
423425 optional codeBlockStart
@@ -451,7 +453,7 @@ rawBlock = try $ do
451453-- block quotes
452454--
453455
454−blockQuote :: Parser [Char] ParserState Blocks
456+blockQuote :: RSTParser Blocks
455457blockQuote = do
456458 raw <- indentedBlock
457459 -- parse the extracted block, which may contain various block elements:
@@ -462,10 +464,10 @@ blockQuote = do
462464-- list blocks
463465--
464466
465−list :: Parser [Char] ParserState Blocks
467+list :: RSTParser Blocks
466468list = choice [ bulletList, orderedList, definitionList ] <?> "list"
467469
468−definitionListItem :: Parser [Char] ParserState (Inlines, [Blocks])
470+definitionListItem :: RSTParser (Inlines, [Blocks])
469471definitionListItem = try $ do
470472 -- avoid capturing a directive or comment
471473 notFollowedBy (try $ char '.' >> char '.')
@@ -475,7 +477,7 @@ definitionListItem = try $ do
475477 contents <- parseFromString parseBlocks $ raw ++ "\n"
476478 return (term, [contents])
477479
478−definitionList :: Parser [Char] ParserState Blocks
480+definitionList :: RSTParser Blocks
479481definitionList = B.definitionList <$> many1 definitionListItem
480482
481483-- parses bullet list start and returns its length (inc. following whitespace)
@@ -489,14 +491,14 @@ bulletListStart = try $ do
489491-- parses ordered list start and returns its length (inc following whitespace)
490492orderedListStart :: ListNumberStyle
491493 -> ListNumberDelim
492− -> Parser [Char] ParserState Int
494+ -> RSTParser Int
493495orderedListStart style delim = try $ do
494496 (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim)
495497 white <- many1 spaceChar
496498 return $ markerLen + length white
497499
498500-- parse a line of a list item
499−listLine :: Int -> Parser [Char] ParserState [Char]
501+listLine :: Int -> RSTParser [Char]
500502listLine markerLength = try $ do
501503 notFollowedBy blankline
502504 indentWith markerLength
@@ -504,7 +506,7 @@ listLine markerLength = try $ do
504506 return $ line ++ "\n"
505507
506508-- indent by specified number of spaces (or equiv. tabs)
507−indentWith :: Int -> Parser [Char] ParserState [Char]
509+indentWith :: Int -> RSTParser [Char]
508510indentWith num = do
509511 tabStop <- getOption readerTabStop
510512 if (num < tabStop)
@@ -513,8 +515,8 @@ indentWith num = do
513515 (try (char '\t' >> count (num - tabStop) (char ' '))) ]
514516
515517-- parse raw text for one list item, excluding start marker and continuations
516−rawListItem :: Parser [Char] ParserState Int
517− -> Parser [Char] ParserState (Int, [Char])
518+rawListItem :: RSTParser Int
519+ -> RSTParser (Int, [Char])
518520rawListItem start = try $ do
519521 markerLength <- start
520522 firstLine <- manyTill anyChar newline
@@ -524,14 +526,14 @@ rawListItem start = try $ do
524526-- continuation of a list item - indented and separated by blankline or
525527-- (in compact lists) endline.
526528-- Note: nested lists are parsed as continuations.
527−listContinuation :: Int -> Parser [Char] ParserState [Char]
529+listContinuation :: Int -> RSTParser [Char]
528530listContinuation markerLength = try $ do
529531 blanks <- many1 blankline
530532 result <- many1 (listLine markerLength)
531533 return $ blanks ++ concat result
532534
533−listItem :: Parser [Char] ParserState Int
534− -> Parser [Char] ParserState Blocks
535+listItem :: RSTParser Int
536+ -> RSTParser Blocks
535537listItem start = try $ do
536538 (markerLength, first) <- rawListItem start
537539 rest <- many (listContinuation markerLength)
@@ -548,21 +550,21 @@ listItem start = try $ do
548550 updateState (\st -> st {stateParserContext = oldContext})
549551 return parsed
550552
551−orderedList :: Parser [Char] ParserState Blocks
553+orderedList :: RSTParser Blocks
552554orderedList = try $ do
553555 (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar)
554556 items <- many1 (listItem (orderedListStart style delim))
555557 let items' = compactify' items
556558 return $ B.orderedListWith (start, style, delim) items'
557559
558−bulletList :: Parser [Char] ParserState Blocks
560+bulletList :: RSTParser Blocks
559561bulletList = B.bulletList . compactify' <$> many1 (listItem bulletListStart)
560562
561563--
562564-- default-role block
563565--
564566
565−defaultRoleBlock :: Parser [Char] ParserState Blocks
567+defaultRoleBlock :: RSTParser Blocks
566568defaultRoleBlock = try $ do
567569 string ".. default-role::"
568570 -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one
@@ -577,22 +579,42 @@ defaultRoleBlock = try $ do
577579 return mempty
578580
579581--
580−-- unknown directive (e.g. comment)
582+-- unknown directive (e.g. comment, container, compound-paragraph)
581583--
582584
583−unknownDirective :: Parser [Char] st Blocks
584−unknownDirective = try $ do
585+directive :: RSTParser Blocks
586+directive = try $ do
585587 string ".."
586− notFollowedBy (noneOf " \t\n")
587− manyTill anyChar newline
588− many $ blanklines <|> (spaceChar >> manyTill anyChar newline)
589− return mempty
588+ lookAhead (char '\n') <|> spaceChar
589+ skipMany spaceChar
590+ label <- option "" $ try $ many1Till letter (try $ string "::")
591+ skipMany spaceChar
592+ top <- many $ satisfy (/='\n')
593+ <|> try (char '\n' <* notFollowedBy blankline <*
594+ notFollowedBy' (lookAhead (many spaceChar)
595+ >>= rawFieldListItem))
596+ newline
597+ indent <- lookAhead $ many spaceChar
598+ fields <- many $ rawFieldListItem indent
599+ blanklines
600+ body <- option "" indentedBlock
601+ let body' = body ++ "\n\n"
602+ case label of
603+ "" -> return mempty
604+ "container" -> parseFromString parseBlocks body'
605+ "compound" -> parseFromString parseBlocks body'
606+ "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
607+ "epigraph" -> B.blockQuote <$> parseFromString parseBlocks body'
608+ "highlights" -> B.blockQuote <$> parseFromString parseBlocks body'
609+ "rubric" -> B.para . B.strong <$> parseFromString
610+ (trimInlines . mconcat <$> many inline) top
611+ _ -> return mempty
590612
591613---
592614--- note block
593615---
594616
595−noteBlock :: Parser [Char] ParserState [Char]
617+noteBlock :: RSTParser [Char]
596618noteBlock = try $ do
597619 startPos <- getPosition
598620 string ".."
@@ -611,7 +633,7 @@ noteBlock = try $ do
611633 -- return blanks so line count isn't affected
612634 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
613635
614−noteMarker :: Parser [Char] ParserState [Char]
636+noteMarker :: RSTParser [Char]
615637noteMarker = do
616638 char '['
617639 res <- many1 digit
@@ -624,13 +646,13 @@ noteMarker = do
624646-- reference key
625647--
626648
627−quotedReferenceName :: Parser [Char] ParserState Inlines
649+quotedReferenceName :: RSTParser Inlines
628650quotedReferenceName = try $ do
629651 char '`' >> notFollowedBy (char '`') -- `` means inline code!
630652 label' <- trimInlines . mconcat <$> many1Till inline (char '`')
631653 return label'
632654
633−unquotedReferenceName :: Parser [Char] ParserState Inlines
655+unquotedReferenceName :: RSTParser Inlines
634656unquotedReferenceName = try $ do
635657 label' <- trimInlines . mconcat <$> many1Till inline (lookAhead $ char ':')
636658 return label'
@@ -651,12 +673,12 @@ simpleReferenceName = do
651673 raw <- simpleReferenceName'
652674 return $ B.str raw
653675
654−referenceName :: Parser [Char] ParserState Inlines
676+referenceName :: RSTParser Inlines
655677referenceName = quotedReferenceName <|>
656678 (try $ simpleReferenceName >>~ lookAhead (char ':')) <|>
657679 unquotedReferenceName
658680
659−referenceKey :: Parser [Char] ParserState [Char]
681+referenceKey :: RSTParser [Char]
660682referenceKey = do
661683 startPos <- getPosition
662684 choice [imageKey, anonymousKey, regularKey]
@@ -674,7 +696,7 @@ targetURI = do
674696 blanklines
675697 return $ escapeURI $ removeLeadingTrailingSpace $ contents
676698
677−imageKey :: Parser [Char] ParserState ()
699+imageKey :: RSTParser ()
678700imageKey = try $ do
679701 string ".. |"
680702 (alt,ref) <- withRaw (trimInlines . mconcat <$> manyTill inline (char '|'))
@@ -683,7 +705,7 @@ imageKey = try $ do
683705 let key = toKey $ init ref
684706 updateState $ \s -> s{ stateSubstitutions = M.insert key img $ stateSubstitutions s }
685707
686−anonymousKey :: Parser [Char] ParserState ()
708+anonymousKey :: RSTParser ()
687709anonymousKey = try $ do
688710 oneOfStrings [".. __:", "__"]
689711 src <- targetURI
@@ -696,7 +718,7 @@ stripTicks = reverse . stripTick . reverse . stripTick
696718 where stripTick ('`':xs) = xs
697719 stripTick xs = xs
698720
699−regularKey :: Parser [Char] ParserState ()
721+regularKey :: RSTParser ()
700722regularKey = try $ do
701723 string ".. _"
702724 (_,ref) <- withRaw referenceName
@@ -732,21 +754,21 @@ simpleDashedLines :: Char -> Parser [Char] st [(Int,Int)]
732754simpleDashedLines ch = try $ many1 (dashedLine ch)
733755
734756-- Parse a table row separator
735−simpleTableSep :: Char -> Parser [Char] ParserState Char
757+simpleTableSep :: Char -> RSTParser Char
736758simpleTableSep ch = try $ simpleDashedLines ch >> newline
737759
738760-- Parse a table footer
739−simpleTableFooter :: Parser [Char] ParserState [Char]
761+simpleTableFooter :: RSTParser [Char]
740762simpleTableFooter = try $ simpleTableSep '=' >> blanklines
741763
742764-- Parse a raw line and split it into chunks by indices.
743−simpleTableRawLine :: [Int] -> Parser [Char] ParserState [String]
765+simpleTableRawLine :: [Int] -> RSTParser [String]
744766simpleTableRawLine indices = do
745767 line <- many1Till anyChar newline
746768 return (simpleTableSplitLine indices line)
747769
748770-- Parse a table row and return a list of blocks (columns).
749−simpleTableRow :: [Int] -> Parser [Char] ParserState [[Block]]
771+simpleTableRow :: [Int] -> RSTParser [[Block]]
750772simpleTableRow indices = do
751773 notFollowedBy' simpleTableFooter
752774 firstLine <- simpleTableRawLine indices
@@ -760,7 +782,7 @@ simpleTableSplitLine indices line =
760782 $ tail $ splitByIndices (init indices) line
761783
762784simpleTableHeader :: Bool -- ^ Headerless table
763− -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
785+ -> RSTParser ([[Block]], [Alignment], [Int])
764786simpleTableHeader headless = try $ do
765787 optional blanklines
766788 rawContent <- if headless
@@ -780,7 +802,7 @@ simpleTableHeader headless = try $ do
780802
781803-- Parse a simple table.
782804simpleTable :: Bool -- ^ Headerless table
783− -> Parser [Char] ParserState Blocks
805+ -> RSTParser Blocks
784806simpleTable headless = do
785807 Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter
786808 -- Simple tables get 0s for relative column widths (i.e., use default)
@@ -789,11 +811,11 @@ simpleTable headless = do
789811 sep = return () -- optional (simpleTableSep '-')
790812
791813gridTable :: Bool -- ^ Headerless table
792− -> Parser [Char] ParserState Blocks
814+ -> RSTParser Blocks
793815gridTable headerless = B.singleton
794816 <$> gridTableWith (B.toList <$> parseBlocks) headerless
795817
796−table :: Parser [Char] ParserState Blocks
818+table :: RSTParser Blocks
797819table = gridTable False <|> simpleTable False <|>
798820 gridTable True <|> simpleTable True <?> "table"
799821
@@ -801,7 +823,7 @@ table = gridTable False <|> simpleTable False <|>
801823-- inline
802824--
803825
804−inline :: Parser [Char] ParserState Inlines
826+inline :: RSTParser Inlines
805827inline = choice [ whitespace
806828 , link
807829 , str
@@ -819,7 +841,7 @@ inline = choice [ whitespace
819841 , escapedChar
820842 , symbol ] <?> "inline"
821843
822−hyphens :: Parser [Char] ParserState Inlines
844+hyphens :: RSTParser Inlines
823845hyphens = do
824846 result <- many1 (char '-')
825847 optional endline
@@ -832,13 +854,13 @@ escapedChar = do c <- escaped anyChar
832854 then mempty
833855 else B.str [c]
834856
835−symbol :: Parser [Char] ParserState Inlines
857+symbol :: RSTParser Inlines
836858symbol = do
837859 result <- oneOf specialChars
838860 return $ B.str [result]
839861
840862-- parses inline code, between codeStart and codeEnd
841−code :: Parser [Char] ParserState Inlines
863+code :: RSTParser Inlines
842864code = try $ do
843865 string "``"
844866 result <- manyTill anyChar (try (string "``"))
@@ -846,7 +868,7 @@ code = try $ do
846868 $ removeLeadingTrailingSpace $ unwords $ lines result
847869
848870-- succeeds only if we're not right after a str (ie. in middle of word)
849−atStart :: Parser [Char] ParserState a -> Parser [Char] ParserState a
871+atStart :: RSTParser a -> RSTParser a
850872atStart p = do
851873 pos <- getPosition
852874 st <- getState
@@ -854,18 +876,18 @@ atStart p = do
854876 guard $ stateLastStrPos st /= Just pos
855877 p
856878
857−emph :: Parser [Char] ParserState Inlines
879+emph :: RSTParser Inlines
858880emph = B.emph . trimInlines . mconcat <$>
859881 enclosed (atStart $ char '*') (char '*') inline
860882
861−strong :: Parser [Char] ParserState Inlines
883+strong :: RSTParser Inlines
862884strong = B.strong . trimInlines . mconcat <$>
863885 enclosed (atStart $ string "**") (try $ string "**") inline
864886
865887-- Parses inline interpreted text which is required to have the given role.
866888-- This decision is based on the role marker (if present),
867889-- and the current default interpreted text role.
868−interpreted :: [Char] -> Parser [Char] ParserState [Char]
890+interpreted :: [Char] -> RSTParser [Char]
869891interpreted role = try $ do
870892 state <- getState
871893 if role == stateRstDefaultRole state
@@ -882,19 +904,19 @@ interpreted role = try $ do
882904 result <- enclosed (atStart $ char '`') (char '`') anyChar
883905 return result
884906
885−superscript :: Parser [Char] ParserState Inlines
907+superscript :: RSTParser Inlines
886908superscript = B.superscript . B.str <$> interpreted "sup"
887909
888−subscript :: Parser [Char] ParserState Inlines
910+subscript :: RSTParser Inlines
889911subscript = B.subscript . B.str <$> interpreted "sub"
890912
891−math :: Parser [Char] ParserState Inlines
913+math :: RSTParser Inlines
892914math = B.math <$> interpreted "math"
893915
894−whitespace :: Parser [Char] ParserState Inlines
916+whitespace :: RSTParser Inlines
895917whitespace = B.space <$ skipMany1 spaceChar <?> "whitespace"
896918
897−str :: Parser [Char] ParserState Inlines
919+str :: RSTParser Inlines
898920str = do
899921 let strChar = noneOf ("\t\n " ++ specialChars)
900922 result <- many1 strChar
@@ -902,7 +924,7 @@ str = do
902924 return $ B.str result
903925
904926-- an endline character that can be treated as a space, not a structural break
905−endline :: Parser [Char] ParserState Inlines
927+endline :: RSTParser Inlines
906928endline = try $ do
907929 newline
908930 notFollowedBy blankline
@@ -918,10 +940,10 @@ endline = try $ do
918940-- links
919941--
920942
921−link :: Parser [Char] ParserState Inlines
943+link :: RSTParser Inlines
922944link = choice [explicitLink, referenceLink, autoLink] <?> "link"
923945
924−explicitLink :: Parser [Char] ParserState Inlines
946+explicitLink :: RSTParser Inlines
925947explicitLink = try $ do
926948 char '`'
927949 notFollowedBy (char '`') -- `` marks start of inline code
@@ -932,7 +954,7 @@ explicitLink = try $ do
932954 string "`_"
933955 return $ B.link (escapeURI $ removeLeadingTrailingSpace src) "" label'
934956
935−referenceLink :: Parser [Char] ParserState Inlines
957+referenceLink :: RSTParser Inlines
936958referenceLink = try $ do
937959 (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) >>~
938960 char '_'
@@ -953,21 +975,21 @@ referenceLink = try $ do
953975 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
954976 return $ B.link src tit label'
955977
956−autoURI :: Parser [Char] ParserState Inlines
978+autoURI :: RSTParser Inlines
957979autoURI = do
958980 (orig, src) <- uri
959981 return $ B.link src "" $ B.str orig
960982
961−autoEmail :: Parser [Char] ParserState Inlines
983+autoEmail :: RSTParser Inlines
962984autoEmail = do
963985 (orig, src) <- emailAddress
964986 return $ B.link src "" $ B.str orig
965987
966−autoLink :: Parser [Char] ParserState Inlines
988+autoLink :: RSTParser Inlines
967989autoLink = autoURI <|> autoEmail
968990
969991-- For now, we assume that all substitution references are for images.
970−image :: Parser [Char] ParserState Inlines
992+image :: RSTParser Inlines
971993image = try $ do
972994 char '|'
973995 (_,ref) <- withRaw (manyTill inline (char '|'))
@@ -977,7 +999,7 @@ image = try $ do
977999 Nothing -> fail "no corresponding key"
9781000 Just target -> return target
9791001
980−note :: Parser [Char] ParserState Inlines
1002+note :: RSTParser Inlines
9811003note = try $ do
9821004 ref <- noteMarker
9831005 char '_'
@@ -1000,20 +1022,20 @@ note = try $ do
10001022 updateState $ \st -> st{ stateNotes = newnotes }
10011023 return $ B.note contents
10021024
1003−smart :: Parser [Char] ParserState Inlines
1025+smart :: RSTParser Inlines
10041026smart = do
10051027 getOption readerSmart >>= guard
10061028 doubleQuoted <|> singleQuoted <|>
10071029 choice (map (B.singleton <$>) [apostrophe, dash, ellipses])
10081030
1009−singleQuoted :: Parser [Char] ParserState Inlines
1031+singleQuoted :: RSTParser Inlines
10101032singleQuoted = try $ do
10111033 singleQuoteStart
10121034 withQuoteContext InSingleQuote $
10131035 B.singleQuoted . trimInlines . mconcat <$>
10141036 many1Till inline singleQuoteEnd
10151037
1016−doubleQuoted :: Parser [Char] ParserState Inlines
1038+doubleQuoted :: RSTParser Inlines
10171039doubleQuoted = try $ do
10181040 doubleQuoteStart
10191041 withQuoteContext InDoubleQuote $