From fe246ce01c4c523b7391d58d910af09bf3bac6e6 Mon Sep 17 00:00:00 2001 From: Merijn Verstraaten Date: Sat, 15 Feb 2014 17:51:33 +0100 Subject: Enhanced Pandoc's support for rST roles. rST parser now supports: - All built-in rST roles - New role definition - Role inheritance Issues/TODO: - Silently ignores illegal fields on roles - Silently drops class annotations for roles - Only supports :format: fields with a single format for :raw: roles, requires a change to Text.Pandoc.Definition.Format to support multiple formats. - Allows direct use of :raw: role, rST only allows indirect (i.e., inherited use of :raw:). --- src/Text/Pandoc/Parsing.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Text/Pandoc/Parsing.hs') diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 2f21e1253..0713f4a96 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -853,6 +853,7 @@ data ParserState = ParserState stateHasChapters :: Bool, -- ^ True if \chapter encountered stateMacros :: [Macro], -- ^ List of macros defined so far stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role + stateRstCustomRoles :: M.Map String (String, Maybe String, Attr -> (String, Attr)), -- ^ Current rST custom text roles stateWarnings :: [String] -- ^ Warnings generated by the parser } @@ -915,6 +916,7 @@ defaultParserState = stateHasChapters = False, stateMacros = [], stateRstDefaultRole = "title-reference", + stateRstCustomRoles = M.empty, stateWarnings = []} getOption :: (ReaderOptions -> a) -> Parser s ParserState a -- cgit v1.2.3 From 66fd9bf7595cd97ccd24b0d64748c852dc604ce8 Mon Sep 17 00:00:00 2001 From: Merijn Verstraaten Date: Sat, 15 Feb 2014 17:57:08 +0100 Subject: Clarified field values in RstCustomRoles. --- src/Text/Pandoc/Parsing.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Text/Pandoc/Parsing.hs') diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 0713f4a96..2bc351db3 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -854,6 +854,10 @@ data ParserState = ParserState stateMacros :: [Macro], -- ^ List of macros defined so far stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role stateRstCustomRoles :: M.Map String (String, Maybe String, Attr -> (String, Attr)), -- ^ Current rST custom text roles + -- Triple represents: 1) Base role, 2) Optional format (only for :raw: + -- roles), 3) Source language annotation for code (could be used to + -- annotate role classes too). + stateWarnings :: [String] -- ^ Warnings generated by the parser } -- cgit v1.2.3