git.iko.soy/typeable/pandoc
on master help sign in
Options -> ReaderOptions.
dfa1906John MacFarlane
src/Tests/Readers/Markdown.hs+1−1
@@ -15,7 +15,7 @@ markdown = readMarkdown defaultParserState{ stateStandalone = True }
15markdownSmart :: String -> Pandoc
15markdownSmart :: String -> Pandoc
16markdownSmart = readMarkdown defaultParserState{ stateOptions =
16markdownSmart = readMarkdown defaultParserState{ stateOptions =
17 let oldOpts = stateOptions defaultParserState in
17 let oldOpts = stateOptions defaultParserState in
18− oldOpts { optionSmart = True } }
18+ oldOpts { readerSmart = True } }
19
19
20infix 4 =:
20infix 4 =:
21(=:) :: ToString c
21(=:) :: ToString c
src/Text/Pandoc/Options.hs+10−10
@@ -29,7 +29,7 @@ Data structures and functions for representing parser and writer
29options.
29options.
30-}
30-}
31module Text.Pandoc.Options ( Extension(..)
31module Text.Pandoc.Options ( Extension(..)
32− , Options(..)
32+ , ReaderOptions(..)
33 ) where
33 ) where
34import Data.Set (Set)
34import Data.Set (Set)
35import qualified Data.Set as Set
35import qualified Data.Set as Set
@@ -50,15 +50,15 @@ data Extension = Footnotes
50 | Significant_bullets
50 | Significant_bullets
51 deriving (Show, Read, Enum, Eq, Ord, Bounded)
51 deriving (Show, Read, Enum, Eq, Ord, Bounded)
52
52
53−data Options = Options{
53+data ReaderOptions = ReaderOptions{
54− optionExtensions :: Set Extension
54+ readerExtensions :: Set Extension
55− , optionSmart :: Bool
55+ , readerSmart :: Bool
56− , optionStrict :: Bool -- FOR TRANSITION ONLY
56+ , readerStrict :: Bool -- FOR TRANSITION ONLY
57 } deriving (Show, Read)
57 } deriving (Show, Read)
58
58
59−instance Default Options
59+instance Default ReaderOptions
60− where def = Options{
60+ where def = ReaderOptions{
61− optionExtensions = Set.fromList [minBound..maxBound]
61+ readerExtensions = Set.fromList [minBound..maxBound]
62− , optionSmart = False
62+ , readerSmart = False
63− , optionStrict = False
63+ , readerStrict = False
64 }
64 }
src/Text/Pandoc/Parsing.hs+3−3
@@ -392,7 +392,7 @@ nullBlock = anyChar >> return Null
392failIfStrict :: Parsec [a] ParserState ()
392failIfStrict :: Parsec [a] ParserState ()
393failIfStrict = do
393failIfStrict = do
394 state <- getState
394 state <- getState
395− if optionStrict (stateOptions state) then fail "strict mode" else return ()
395+ if readerStrict (stateOptions state) then fail "strict mode" else return ()
396
396
397-- | Fail unless we're in literate haskell mode.
397-- | Fail unless we're in literate haskell mode.
398failUnlessLHS :: Parsec [tok] ParserState ()
398failUnlessLHS :: Parsec [tok] ParserState ()
@@ -689,7 +689,7 @@ testStringWith parser str = UTF8.putStrLn $ show $
689
689
690-- | Parsing options.
690-- | Parsing options.
691data ParserState = ParserState
691data ParserState = ParserState
692− { stateOptions :: Options, -- ^ User options
692+ { stateOptions :: ReaderOptions, -- ^ User options
693 stateParseRaw :: Bool, -- ^ Parse raw HTML and LaTeX?
693 stateParseRaw :: Bool, -- ^ Parse raw HTML and LaTeX?
694 stateParserContext :: ParserContext, -- ^ Inside list?
694 stateParserContext :: ParserContext, -- ^ Inside list?
695 stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
695 stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
@@ -795,7 +795,7 @@ lookupKeySrc table key = case M.lookup key table of
795
795
796-- | Fail unless we're in "smart typography" mode.
796-- | Fail unless we're in "smart typography" mode.
797failUnlessSmart :: Parsec [tok] ParserState ()
797failUnlessSmart :: Parsec [tok] ParserState ()
798−failUnlessSmart = getState >>= guard . optionSmart . stateOptions
798+failUnlessSmart = getState >>= guard . readerSmart . stateOptions
799
799
800smartPunctuation :: Parsec [Char] ParserState Inline
800smartPunctuation :: Parsec [Char] ParserState Inline
801 -> Parsec [Char] ParserState Inline
801 -> Parsec [Char] ParserState Inline
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -126,7 +126,7 @@ pOrderedList :: TagParser [Block]
126pOrderedList = try $ do
126pOrderedList = try $ do
127 TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
127 TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
128 st <- getState
128 st <- getState
129− let (start, style) = if optionStrict (stateOptions st)
129+ let (start, style) = if readerStrict (stateOptions st)
130 then (1, DefaultStyle)
130 then (1, DefaultStyle)
131 else (sta', sty')
131 else (sta', sty')
132 where sta = fromMaybe "1" $
132 where sta = fromMaybe "1" $
@@ -281,7 +281,7 @@ pCodeBlock = try $ do
281 let attribsClasses = words $ fromMaybe "" $ lookup "class" attr
281 let attribsClasses = words $ fromMaybe "" $ lookup "class" attr
282 let attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
282 let attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
283 st <- getState
283 st <- getState
284− let attribs = if optionStrict (stateOptions st)
284+ let attribs = if readerStrict (stateOptions st)
285 then ("",[],[])
285 then ("",[],[])
286 else (attribsId, attribsClasses, attribsKV)
286 else (attribsId, attribsClasses, attribsKV)
287 return [CodeBlock attribs result]
287 return [CodeBlock attribs result]
src/Text/Pandoc/Readers/Markdown.hs+10−10
@@ -182,7 +182,7 @@ parseMarkdown = do
182 -- docMinusKeys is the raw document with blanks where the keys/notes were...
182 -- docMinusKeys is the raw document with blanks where the keys/notes were...
183 st <- getState
183 st <- getState
184 let firstPassParser = referenceKey
184 let firstPassParser = referenceKey
185− <|> (if optionStrict (stateOptions st) then mzero else noteBlock)
185+ <|> (if readerStrict (stateOptions st) then mzero else noteBlock)
186 <|> liftM snd (withRaw codeBlockDelimited)
186 <|> liftM snd (withRaw codeBlockDelimited)
187 <|> lineClump
187 <|> lineClump
188 docMinusKeys <- liftM concat $ manyTill firstPassParser eof
188 docMinusKeys <- liftM concat $ manyTill firstPassParser eof
@@ -293,7 +293,7 @@ parseBlocks = manyTill block eof
293block :: Parser [Char] ParserState Block
293block :: Parser [Char] ParserState Block
294block = do
294block = do
295 st <- getState
295 st <- getState
296− choice (if optionStrict (stateOptions st)
296+ choice (if readerStrict (stateOptions st)
297 then [ header
297 then [ header
298 , codeBlockIndented
298 , codeBlockIndented
299 , blockQuote
299 , blockQuote
@@ -534,7 +534,7 @@ anyOrderedListStart = try $ do
534 skipNonindentSpaces
534 skipNonindentSpaces
535 notFollowedBy $ string "p." >> spaceChar >> digit -- page number
535 notFollowedBy $ string "p." >> spaceChar >> digit -- page number
536 state <- getState
536 state <- getState
537− if optionStrict (stateOptions state)
537+ if readerStrict (stateOptions state)
538 then do many1 digit
538 then do many1 digit
539 char '.'
539 char '.'
540 spaceChar
540 spaceChar
@@ -695,7 +695,7 @@ para = try $ do
695 option (Plain result) $ try $ do
695 option (Plain result) $ try $ do
696 newline
696 newline
697 blanklines <|>
697 blanklines <|>
698− (getState >>= guard . optionStrict . stateOptions >>
698+ (getState >>= guard . readerStrict . stateOptions >>
699 lookAhead (blockQuote <|> header) >> return "")
699 lookAhead (blockQuote <|> header) >> return "")
700 return $ Para result
700 return $ Para result
701
701
@@ -1009,7 +1009,7 @@ escapedChar' :: Parser [Char] ParserState Char
1009escapedChar' = try $ do
1009escapedChar' = try $ do
1010 char '\\'
1010 char '\\'
1011 state <- getState
1011 state <- getState
1012− if optionStrict (stateOptions state)
1012+ if readerStrict (stateOptions state)
1013 then oneOf "\\`*_{}[]()>#+-.!~"
1013 then oneOf "\\`*_{}[]()>#+-.!~"
1014 else satisfy (not . isAlphaNum)
1014 else satisfy (not . isAlphaNum)
1015
1015
@@ -1024,7 +1024,7 @@ escapedChar = do
1024ltSign :: Parser [Char] ParserState Inline
1024ltSign :: Parser [Char] ParserState Inline
1025ltSign = do
1025ltSign = do
1026 st <- getState
1026 st <- getState
1027− if optionStrict (stateOptions st)
1027+ if readerStrict (stateOptions st)
1028 then char '<'
1028 then char '<'
1029 else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html
1029 else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html
1030 return $ Str ['<']
1030 return $ Str ['<']
@@ -1160,7 +1160,7 @@ nonEndline = satisfy (/='\n')
1160
1160
1161str :: Parser [Char] ParserState Inline
1161str :: Parser [Char] ParserState Inline
1162str = do
1162str = do
1163− smart <- (optionSmart . stateOptions) `fmap` getState
1163+ smart <- (readerSmart . stateOptions) `fmap` getState
1164 a <- alphaNum
1164 a <- alphaNum
1165 as <- many $ alphaNum
1165 as <- many $ alphaNum
1166 <|> (try $ char '_' >>~ lookAhead alphaNum)
1166 <|> (try $ char '_' >>~ lookAhead alphaNum)
@@ -1201,7 +1201,7 @@ endline = try $ do
1201 newline
1201 newline
1202 notFollowedBy blankline
1202 notFollowedBy blankline
1203 st <- getState
1203 st <- getState
1204− when (optionStrict (stateOptions st)) $ do
1204+ when (readerStrict (stateOptions st)) $ do
1205 notFollowedBy emailBlockQuoteStart
1205 notFollowedBy emailBlockQuoteStart
1206 notFollowedBy (char '#') -- atx header
1206 notFollowedBy (char '#') -- atx header
1207 -- parse potential list-starts differently if in a list:
1207 -- parse potential list-starts differently if in a list:
@@ -1283,7 +1283,7 @@ autoLink = try $ do
1283 (orig, src) <- uri <|> emailAddress
1283 (orig, src) <- uri <|> emailAddress
1284 char '>'
1284 char '>'
1285 st <- getState
1285 st <- getState
1286− return $ if optionStrict (stateOptions st)
1286+ return $ if readerStrict (stateOptions st)
1287 then Link [Str orig] (src, "")
1287 then Link [Str orig] (src, "")
1288 else Link [Code ("",["url"],[]) orig] (src, "")
1288 else Link [Code ("",["url"],[]) orig] (src, "")
1289
1289
@@ -1344,7 +1344,7 @@ inBrackets parser = do
1344rawHtmlInline :: Parser [Char] ParserState Inline
1344rawHtmlInline :: Parser [Char] ParserState Inline
1345rawHtmlInline = do
1345rawHtmlInline = do
1346 st <- getState
1346 st <- getState
1347− (_,result) <- if optionStrict (stateOptions st)
1347+ (_,result) <- if readerStrict (stateOptions st)
1348 then htmlTag (not . isTextTag)
1348 then htmlTag (not . isTextTag)
1349 else htmlTag isInlineTag
1349 else htmlTag isInlineTag
1350 return $ RawInline "html" result
1350 return $ RawInline "html" result
src/Text/Pandoc/Readers/Textile.hs+1−1
@@ -80,7 +80,7 @@ parseTextile = do
80 -- textile allows raw HTML and does smart punctuation by default
80 -- textile allows raw HTML and does smart punctuation by default
81 oldOpts <- stateOptions `fmap` getState
81 oldOpts <- stateOptions `fmap` getState
82 updateState $ \state -> state { stateParseRaw = True
82 updateState $ \state -> state { stateParseRaw = True
83− , stateOptions = oldOpts{ optionSmart = True }
83+ , stateOptions = oldOpts{ readerSmart = True }
84 }
84 }
85 many blankline
85 many blankline
86 startPos <- getPosition
86 startPos <- getPosition
src/pandoc.hs+2−2
@@ -944,8 +944,8 @@ main = do
944 stateCitations = map CSL.refId refs,
944 stateCitations = map CSL.refId refs,
945 stateOldDashes = oldDashes,
945 stateOldDashes = oldDashes,
946 stateColumns = columns,
946 stateColumns = columns,
947− stateOptions = def{ optionStrict = strict
947+ stateOptions = def{ readerStrict = strict
948− , optionSmart = smart ||
948+ , readerSmart = smart ||
949 (texLigatures &&
949 (texLigatures &&
950 (laTeXOutput || writerName' == "context")) },
950 (laTeXOutput || writerName' == "context")) },
951 stateIndentedCodeClasses = codeBlockClasses,
951 stateIndentedCodeClasses = codeBlockClasses,