Moved stateOldDashes to readerOldDashes in ReaderOptions.

This commit is contained in:
John MacFarlane
2012-07-25 12:37:04 -07:00
parent 335cd5de4d
commit 95570ba34c
4 changed files with 13 additions and 11 deletions
+5 -1
View File
@@ -57,7 +57,10 @@ data ReaderOptions = ReaderOptions{
, readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX
, readerColumns :: Int -- ^ Number of columns in terminal
, readerTabStop :: Int -- ^ Tab stop
} deriving (Show, Read)
, readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior
-- in parsing dashes; -- is em-dash;
-- - before numerial is en-dash
} deriving (Show, Read)
instance Default ReaderOptions
where def = ReaderOptions{
@@ -67,4 +70,5 @@ instance Default ReaderOptions
, readerParseRaw = False
, readerColumns = 80
, readerTabStop = 4
, readerOldDashes = False
}
+1 -5
View File
@@ -699,9 +699,6 @@ data ParserState = ParserState
stateTitle :: [Inline], -- ^ Title of document
stateAuthors :: [[Inline]], -- ^ Authors of document
stateDate :: [Inline], -- ^ Date of document
stateOldDashes :: Bool, -- ^ Use pandoc <= 1.8.2.1 behavior
-- in parsing dashes; -- is em-dash;
-- before numeral is en-dash
stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks
@@ -731,7 +728,6 @@ defaultParserState =
stateTitle = [],
stateAuthors = [],
stateDate = [],
stateOldDashes = False,
stateLiterateHaskell = False,
stateHeaderTable = [],
stateIndentedCodeClasses = [],
@@ -887,7 +883,7 @@ ellipses = do
dash :: Parsec [Char] ParserState Inline
dash = do
oldDashes <- stateOldDashes `fmap` getState
oldDashes <- getOption readerOldDashes
if oldDashes
then emDashOld <|> enDashOld
else Str `fmap` (hyphenDash <|> emDash <|> enDash)
+6 -4
View File
@@ -71,7 +71,7 @@ readTextile :: ParserState -- ^ Parser state, including options for parser
-> String -- ^ String to parse (assuming @'\n'@ line endings)
-> Pandoc
readTextile state s =
(readWith parseTextile) state{ stateOldDashes = True } (s ++ "\n\n")
(readWith parseTextile) state (s ++ "\n\n")
-- | Generate a Pandoc ADT from a textile document
@@ -79,9 +79,11 @@ parseTextile :: Parser [Char] ParserState Pandoc
parseTextile = do
-- textile allows raw HTML and does smart punctuation by default
oldOpts <- stateOptions `fmap` getState
updateState $ \state -> state{ stateOptions = oldOpts{ readerSmart = True
, readerParseRaw = True
} }
updateState $ \state -> state{ stateOptions =
oldOpts{ readerSmart = True
, readerParseRaw = True
, readerOldDashes = True
} }
many blankline
startPos <- getPosition
-- go through once just to get list of reference keys and notes
+1 -1
View File
@@ -940,7 +940,6 @@ main = do
lhsExtension sources,
stateStandalone = standalone',
stateCitations = map CSL.refId refs,
stateOldDashes = oldDashes,
stateOptions = def{
readerStrict = strict
, readerSmart = smart || (texLigatures &&
@@ -948,6 +947,7 @@ main = do
, readerParseRaw = parseRaw
, readerColumns = columns
, readerTabStop = tabStop
, readerOldDashes = oldDashes
},
stateIndentedCodeClasses = codeBlockClasses,
stateApplyMacros = not laTeXOutput