git.iko.soy/typeable/pandoc
on master help sign in
Moved stateTabStop to readerTabStop in ReaderOptions.
commit335cd5de4d785f09ae1c14e961df8c4137300252 authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 25 Jul 2012, 12:31 (14 years ago) parent0d4424c
5 files changed+11−15
src/Text/Pandoc/Options.hs+2 src/Text/Pandoc/Parsing.hs−3 src/Text/Pandoc/Readers/Markdown.hs+5−8 src/Text/Pandoc/Readers/RST.hs+2−2 src/pandoc.hs+2−2
src/Text/Pandoc/Options.hs+2
@@ -56,6 +56,7 @@ data ReaderOptions = ReaderOptions{
5656 , readerStrict :: Bool -- ^ FOR TRANSITION ONLY
5757 , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX
5858 , readerColumns :: Int -- ^ Number of columns in terminal
59+ , readerTabStop :: Int -- ^ Tab stop
5960 } deriving (Show, Read)
6061
6162instance Default ReaderOptions
@@ -65,4 +66,5 @@ instance Default ReaderOptions
6566 , readerStrict = False
6667 , readerParseRaw = False
6768 , readerColumns = 80
69+ , readerTabStop = 4
6870 }
src/Text/Pandoc/Parsing.hs−3
@@ -544,7 +544,6 @@ tableWith headerParser rowParser lineParser footerParser = try $ do
544544 (heads, aligns, indices) <- headerParser
545545 lines' <- rowParser indices `sepEndBy1` lineParser
546546 footerParser
547− state <- getState
548547 numColumns <- getOption readerColumns
549548 let widths = if (indices == [])
550549 then replicate (length aligns) 0.0
@@ -696,7 +695,6 @@ data ParserState = ParserState
696695 stateKeys :: KeyTable, -- ^ List of reference keys
697696 stateCitations :: [String], -- ^ List of available citations
698697 stateNotes :: NoteTable, -- ^ List of notes
699− stateTabStop :: Int, -- ^ Tab stop
700698 stateStandalone :: Bool, -- ^ Parse bibliographic info?
701699 stateTitle :: [Inline], -- ^ Title of document
702700 stateAuthors :: [[Inline]], -- ^ Authors of document
@@ -729,7 +727,6 @@ defaultParserState =
729727 stateKeys = M.empty,
730728 stateCitations = [],
731729 stateNotes = [],
732− stateTabStop = 4,
733730 stateStandalone = False,
734731 stateTitle = [],
735732 stateAuthors = [],
src/Text/Pandoc/Readers/Markdown.hs+5−8
@@ -85,15 +85,13 @@ isBlank _ = False
8585
8686indentSpaces :: Parser [Char] ParserState [Char]
8787indentSpaces = try $ do
88− state <- getState
89− let tabStop = stateTabStop state
88+ tabStop <- getOption readerTabStop
9089 count tabStop (char ' ') <|>
9190 string "\t" <?> "indentation"
9291
9392nonindentSpaces :: Parser [Char] ParserState [Char]
9493nonindentSpaces = do
95− state <- getState
96− let tabStop = stateTabStop state
94+ tabStop <- getOption readerTabStop
9795 sps <- many (char ' ')
9896 if length sps < tabStop
9997 then return sps
@@ -101,8 +99,8 @@ nonindentSpaces = do
10199
102100skipNonindentSpaces :: Parser [Char] ParserState ()
103101skipNonindentSpaces = do
104− state <- getState
105− atMostSpaces (stateTabStop state - 1)
102+ tabStop <- getOption readerTabStop
103+ atMostSpaces (tabStop - 1)
106104
107105atMostSpaces :: Int -> Parser [Char] ParserState ()
108106atMostSpaces 0 = notFollowedBy (char ' ')
@@ -627,8 +625,7 @@ defListMarker :: Parser [Char] ParserState ()
627625defListMarker = do
628626 sps <- nonindentSpaces
629627 char ':' <|> char '~'
630− st <- getState
631− let tabStop = stateTabStop st
628+ tabStop <- getOption readerTabStop
632629 let remaining = tabStop - (length sps + 1)
633630 if remaining > 0
634631 then count remaining (char ' ') <|> string "\t"
src/Text/Pandoc/Readers/RST.hs+2−2
@@ -33,6 +33,7 @@ module Text.Pandoc.Readers.RST (
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
3535import Text.Pandoc.Parsing
36+import Text.Pandoc.Options
3637import Control.Monad ( when, liftM, guard, mzero )
3738import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
3839import qualified Data.Map as M
@@ -493,8 +494,7 @@ listLine markerLength = try $ do
493494-- indent by specified number of spaces (or equiv. tabs)
494495indentWith :: Int -> Parser [Char] ParserState [Char]
495496indentWith num = do
496− state <- getState
497− let tabStop = stateTabStop state
497+ tabStop <- getOption readerTabStop
498498 if (num < tabStop)
499499 then count num (char ' ')
500500 else choice [ try (count num (char ' ')),
src/pandoc.hs+2−2
@@ -936,8 +936,7 @@ main = do
936936 then "."
937937 else takeDirectory (head sources)
938938
939− let startParserState = def{ stateTabStop = tabStop,
940− stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
939+ let startParserState = def{ stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
941940 lhsExtension sources,
942941 stateStandalone = standalone',
943942 stateCitations = map CSL.refId refs,
@@ -948,6 +947,7 @@ main = do
948947 (laTeXOutput || writerName' == "context"))
949948 , readerParseRaw = parseRaw
950949 , readerColumns = columns
950+ , readerTabStop = tabStop
951951 },
952952 stateIndentedCodeClasses = codeBlockClasses,
953953 stateApplyMacros = not laTeXOutput