git.iko.soy/typeable/pandoc
on master help sign in
Moved stateOldDashes to readerOldDashes in ReaderOptions.
commit95570ba34c4e7675295b6eefcfcc4dac4ac720af authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 25 Jul 2012, 12:37 (14 years ago) parent335cd5d
4 files changed+13−11
src/Text/Pandoc/Options.hs+5−1 src/Text/Pandoc/Parsing.hs+1−5 src/Text/Pandoc/Readers/Textile.hs+6−4 src/pandoc.hs+1−1
src/Text/Pandoc/Options.hs+5−1
@@ -57,7 +57,10 @@ data ReaderOptions = ReaderOptions{
5757 , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX
5858 , readerColumns :: Int -- ^ Number of columns in terminal
5959 , readerTabStop :: Int -- ^ Tab stop
60− } deriving (Show, Read)
60+ , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior
61+ -- in parsing dashes; -- is em-dash;
62+ -- - before numerial is en-dash
63+} deriving (Show, Read)
6164
6265instance Default ReaderOptions
6366 where def = ReaderOptions{
@@ -67,4 +70,5 @@ instance Default ReaderOptions
6770 , readerParseRaw = False
6871 , readerColumns = 80
6972 , readerTabStop = 4
73+ , readerOldDashes = False
7074 }
src/Text/Pandoc/Parsing.hs+1−5
@@ -699,9 +699,6 @@ data ParserState = ParserState
699699 stateTitle :: [Inline], -- ^ Title of document
700700 stateAuthors :: [[Inline]], -- ^ Authors of document
701701 stateDate :: [Inline], -- ^ Date of document
702− stateOldDashes :: Bool, -- ^ Use pandoc <= 1.8.2.1 behavior
703− -- in parsing dashes; -- is em-dash;
704− -- before numeral is en-dash
705702 stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
706703 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
707704 stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks
@@ -731,7 +728,6 @@ defaultParserState =
731728 stateTitle = [],
732729 stateAuthors = [],
733730 stateDate = [],
734− stateOldDashes = False,
735731 stateLiterateHaskell = False,
736732 stateHeaderTable = [],
737733 stateIndentedCodeClasses = [],
@@ -887,7 +883,7 @@ ellipses = do
887883
888884dash :: Parsec [Char] ParserState Inline
889885dash = do
890− oldDashes <- stateOldDashes `fmap` getState
886+ oldDashes <- getOption readerOldDashes
891887 if oldDashes
892888 then emDashOld <|> enDashOld
893889 else Str `fmap` (hyphenDash <|> emDash <|> enDash)
src/Text/Pandoc/Readers/Textile.hs+6−4
@@ -71,7 +71,7 @@ readTextile :: ParserState -- ^ Parser state, including options for parser
7171 -> String -- ^ String to parse (assuming @'\n'@ line endings)
7272 -> Pandoc
7373readTextile state s =
74− (readWith parseTextile) state{ stateOldDashes = True } (s ++ "\n\n")
74+ (readWith parseTextile) state (s ++ "\n\n")
7575
7676
7777-- | Generate a Pandoc ADT from a textile document
@@ -79,9 +79,11 @@ parseTextile :: Parser [Char] ParserState Pandoc
7979parseTextile = do
8080 -- textile allows raw HTML and does smart punctuation by default
8181 oldOpts <- stateOptions `fmap` getState
82− updateState $ \state -> state{ stateOptions = oldOpts{ readerSmart = True
83− , readerParseRaw = True
84− } }
82+ updateState $ \state -> state{ stateOptions =
83+ oldOpts{ readerSmart = True
84+ , readerParseRaw = True
85+ , readerOldDashes = True
86+ } }
8587 many blankline
8688 startPos <- getPosition
8789 -- go through once just to get list of reference keys and notes
src/pandoc.hs+1−1
@@ -940,7 +940,6 @@ main = do
940940 lhsExtension sources,
941941 stateStandalone = standalone',
942942 stateCitations = map CSL.refId refs,
943− stateOldDashes = oldDashes,
944943 stateOptions = def{
945944 readerStrict = strict
946945 , readerSmart = smart || (texLigatures &&
@@ -948,6 +947,7 @@ main = do
948947 , readerParseRaw = parseRaw
949948 , readerColumns = columns
950949 , readerTabStop = tabStop
950+ , readerOldDashes = oldDashes
951951 },
952952 stateIndentedCodeClasses = codeBlockClasses,
953953 stateApplyMacros = not laTeXOutput