git.iko.soy/typeable/pandoc
on master help sign in
Moved stateTabStop to readerTabStop in ReaderOptions.
335cd5dJohn MacFarlane
src/Text/Pandoc/Options.hs+2
@@ -56,6 +56,7 @@ data ReaderOptions = ReaderOptions{
56 , readerStrict :: Bool -- ^ FOR TRANSITION ONLY
56 , readerStrict :: Bool -- ^ FOR TRANSITION ONLY
57 , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX
57 , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX
58 , readerColumns :: Int -- ^ Number of columns in terminal
58 , readerColumns :: Int -- ^ Number of columns in terminal
59+ , readerTabStop :: Int -- ^ Tab stop
59 } deriving (Show, Read)
60 } deriving (Show, Read)
60
61
61instance Default ReaderOptions
62instance Default ReaderOptions
@@ -65,4 +66,5 @@ instance Default ReaderOptions
65 , readerStrict = False
66 , readerStrict = False
66 , readerParseRaw = False
67 , readerParseRaw = False
67 , readerColumns = 80
68 , readerColumns = 80
69+ , readerTabStop = 4
68 }
70 }
src/Text/Pandoc/Parsing.hs−3
@@ -544,7 +544,6 @@ tableWith headerParser rowParser lineParser footerParser = try $ do
544 (heads, aligns, indices) <- headerParser
544 (heads, aligns, indices) <- headerParser
545 lines' <- rowParser indices `sepEndBy1` lineParser
545 lines' <- rowParser indices `sepEndBy1` lineParser
546 footerParser
546 footerParser
547− state <- getState
548 numColumns <- getOption readerColumns
547 numColumns <- getOption readerColumns
549 let widths = if (indices == [])
548 let widths = if (indices == [])
550 then replicate (length aligns) 0.0
549 then replicate (length aligns) 0.0
@@ -696,7 +695,6 @@ data ParserState = ParserState
696 stateKeys :: KeyTable, -- ^ List of reference keys
695 stateKeys :: KeyTable, -- ^ List of reference keys
697 stateCitations :: [String], -- ^ List of available citations
696 stateCitations :: [String], -- ^ List of available citations
698 stateNotes :: NoteTable, -- ^ List of notes
697 stateNotes :: NoteTable, -- ^ List of notes
699− stateTabStop :: Int, -- ^ Tab stop
700 stateStandalone :: Bool, -- ^ Parse bibliographic info?
698 stateStandalone :: Bool, -- ^ Parse bibliographic info?
701 stateTitle :: [Inline], -- ^ Title of document
699 stateTitle :: [Inline], -- ^ Title of document
702 stateAuthors :: [[Inline]], -- ^ Authors of document
700 stateAuthors :: [[Inline]], -- ^ Authors of document
@@ -729,7 +727,6 @@ defaultParserState =
729 stateKeys = M.empty,
727 stateKeys = M.empty,
730 stateCitations = [],
728 stateCitations = [],
731 stateNotes = [],
729 stateNotes = [],
732− stateTabStop = 4,
733 stateStandalone = False,
730 stateStandalone = False,
734 stateTitle = [],
731 stateTitle = [],
735 stateAuthors = [],
732 stateAuthors = [],
src/Text/Pandoc/Readers/Markdown.hs+5−8
@@ -85,15 +85,13 @@ isBlank _ = False
85
85
86indentSpaces :: Parser [Char] ParserState [Char]
86indentSpaces :: Parser [Char] ParserState [Char]
87indentSpaces = try $ do
87indentSpaces = try $ do
88− state <- getState
88+ tabStop <- getOption readerTabStop
89− let tabStop = stateTabStop state
90 count tabStop (char ' ') <|>
89 count tabStop (char ' ') <|>
91 string "\t" <?> "indentation"
90 string "\t" <?> "indentation"
92
91
93nonindentSpaces :: Parser [Char] ParserState [Char]
92nonindentSpaces :: Parser [Char] ParserState [Char]
94nonindentSpaces = do
93nonindentSpaces = do
95− state <- getState
94+ tabStop <- getOption readerTabStop
96− let tabStop = stateTabStop state
97 sps <- many (char ' ')
95 sps <- many (char ' ')
98 if length sps < tabStop
96 if length sps < tabStop
99 then return sps
97 then return sps
@@ -101,8 +99,8 @@ nonindentSpaces = do
101
99
102skipNonindentSpaces :: Parser [Char] ParserState ()
100skipNonindentSpaces :: Parser [Char] ParserState ()
103skipNonindentSpaces = do
101skipNonindentSpaces = do
104− state <- getState
102+ tabStop <- getOption readerTabStop
105− atMostSpaces (stateTabStop state - 1)
103+ atMostSpaces (tabStop - 1)
106
104
107atMostSpaces :: Int -> Parser [Char] ParserState ()
105atMostSpaces :: Int -> Parser [Char] ParserState ()
108atMostSpaces 0 = notFollowedBy (char ' ')
106atMostSpaces 0 = notFollowedBy (char ' ')
@@ -627,8 +625,7 @@ defListMarker :: Parser [Char] ParserState ()
627defListMarker = do
625defListMarker = do
628 sps <- nonindentSpaces
626 sps <- nonindentSpaces
629 char ':' <|> char '~'
627 char ':' <|> char '~'
630− st <- getState
628+ tabStop <- getOption readerTabStop
631− let tabStop = stateTabStop st
632 let remaining = tabStop - (length sps + 1)
629 let remaining = tabStop - (length sps + 1)
633 if remaining > 0
630 if remaining > 0
634 then count remaining (char ' ') <|> string "\t"
631 then count remaining (char ' ') <|> string "\t"
src/Text/Pandoc/Readers/RST.hs+2−2
@@ -33,6 +33,7 @@ module Text.Pandoc.Readers.RST (
33import Text.Pandoc.Definition
33import Text.Pandoc.Definition
34import Text.Pandoc.Shared
34import Text.Pandoc.Shared
35import Text.Pandoc.Parsing
35import Text.Pandoc.Parsing
36+import Text.Pandoc.Options
36import Control.Monad ( when, liftM, guard, mzero )
37import Control.Monad ( when, liftM, guard, mzero )
37import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
38import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
38import qualified Data.Map as M
39import qualified Data.Map as M
@@ -493,8 +494,7 @@ listLine markerLength = try $ do
493-- indent by specified number of spaces (or equiv. tabs)
494-- indent by specified number of spaces (or equiv. tabs)
494indentWith :: Int -> Parser [Char] ParserState [Char]
495indentWith :: Int -> Parser [Char] ParserState [Char]
495indentWith num = do
496indentWith num = do
496− state <- getState
497+ tabStop <- getOption readerTabStop
497− let tabStop = stateTabStop state
498 if (num < tabStop)
498 if (num < tabStop)
499 then count num (char ' ')
499 then count num (char ' ')
500 else choice [ try (count num (char ' ')),
500 else choice [ try (count num (char ' ')),
src/pandoc.hs+2−2
@@ -936,8 +936,7 @@ main = do
936 then "."
936 then "."
937 else takeDirectory (head sources)
937 else takeDirectory (head sources)
938
938
939− let startParserState = def{ stateTabStop = tabStop,
940− stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
939+ let startParserState = def{ stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
941 lhsExtension sources,
940 lhsExtension sources,
942 stateStandalone = standalone',
941 stateStandalone = standalone',
943 stateCitations = map CSL.refId refs,
942 stateCitations = map CSL.refId refs,
@@ -948,6 +947,7 @@ main = do
948 (laTeXOutput || writerName' == "context"))
947 (laTeXOutput || writerName' == "context"))
949 , readerParseRaw = parseRaw
948 , readerParseRaw = parseRaw
950 , readerColumns = columns
949 , readerColumns = columns
950+ , readerTabStop = tabStop
951 },
951 },
952 stateIndentedCodeClasses = codeBlockClasses,
952 stateIndentedCodeClasses = codeBlockClasses,
953 stateApplyMacros = not laTeXOutput
953 stateApplyMacros = not laTeXOutput