@@ -146,6 +146,7 @@ data Opt = Opt
146 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
146 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
147 , optWrapText :: Bool -- ^ Wrap text
147 , optWrapText :: Bool -- ^ Wrap text
148 , optSanitizeHTML :: Bool -- ^ Sanitize HTML
148 , optSanitizeHTML :: Bool -- ^ Sanitize HTML
149+ , optLHSIn :: Bool -- ^ Treat input as literate haskell
149#ifdef _CITEPROC
150#ifdef _CITEPROC
150 , optModsFile :: String
151 , optModsFile :: String
151 , optCslFile :: String
152 , optCslFile :: String
@@ -179,6 +180,7 @@ defaultOpts = Opt
179 , optReferenceLinks = False
180 , optReferenceLinks = False
180 , optWrapText = True
181 , optWrapText = True
181 , optSanitizeHTML = False
182 , optSanitizeHTML = False
182#ifdef _CITEPROC
184#ifdef _CITEPROC
183 , optModsFile = []
185 , optModsFile = []
184 , optCslFile = []
186 , optCslFile = []
@@ -288,6 +290,11 @@ options =
288 (\opt -> return opt { optSanitizeHTML = True }))
290 (\opt -> return opt { optSanitizeHTML = True }))
289 "" -- "Sanitize HTML"
291 "" -- "Sanitize HTML"
293+ , Option "" ["lhs-in"]
295+ (\opt -> return opt { optLHSIn = True }))
296+ "" -- "Treat input as literate haskell"
291 , Option "" ["toc", "table-of-contents"]
298 , Option "" ["toc", "table-of-contents"]
293 (\opt -> return opt { optTableOfContents = True }))
300 (\opt -> return opt { optTableOfContents = True }))
@@ -419,6 +426,11 @@ defaultReaderName (x:xs) =
419 ".native" -> "native"
426 ".native" -> "native"
420 _ -> defaultReaderName xs
427 _ -> defaultReaderName xs
429+-- Returns True if extension of first source is .lhs
430+lhsExtension :: [FilePath] -> Bool
431+lhsExtension (x:_) = takeExtension x == ".lhs"
432+lhsExtension _ = False
422-- Determine default writer based on output file extension
434-- Determine default writer based on output file extension
423defaultWriterName :: FilePath -> String
435defaultWriterName :: FilePath -> String
424defaultWriterName "-" = "html" -- no output file
436defaultWriterName "-" = "html" -- no output file
@@ -498,6 +510,7 @@ main = do
498 , optReferenceLinks = referenceLinks
510 , optReferenceLinks = referenceLinks
499 , optWrapText = wrap
511 , optWrapText = wrap
500 , optSanitizeHTML = sanitize
512 , optSanitizeHTML = sanitize
501#ifdef _CITEPROC
514#ifdef _CITEPROC
502 , optModsFile = modsFile
515 , optModsFile = modsFile
503 , optCslFile = cslFile
516 , optCslFile = cslFile
@@ -556,17 +569,19 @@ main = do
558 let startParserState =
571 let startParserState =
559− defaultParserState { stateParseRaw = parseRaw,
572+ defaultParserState { stateParseRaw = parseRaw,
560− stateTabStop = tabStop,
573+ stateTabStop = tabStop,
561− stateSanitizeHTML = sanitize,
574+ stateSanitizeHTML = sanitize,
575+ stateLiterateHaskell = lhsIn ||
576+ lhsExtension sources,
562− stateStandalone = standalone',
577+ stateStandalone = standalone',
563#ifdef _CITEPROC
578#ifdef _CITEPROC
564− stateCitations = map citeKey refs,
579+ stateCitations = map citeKey refs,
566− stateSmart = smart || writerName' `elem`
581+ stateSmart = smart || writerName' `elem`
567− ["latex", "context"],
582+ ["latex", "context"],
568− stateColumns = columns,
583+ stateColumns = columns,
569− stateStrict = strict }
584+ stateStrict = strict }
570 let csslink = if null css
585 let csslink = if null css
572 else concatMap
587 else concatMap