summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-02 07:37:42 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-02 07:37:42 +0000
commitb9eeba9aa2c8bc5c24f9c1fa5d05ba29e358276b (patch)
treed4afeddb7a5b5e598b96d433c1463d1bf12a6859 /src/Main.hs
parent17be8bc2574ad262b817e7f1d0a220e8c4980118 (diff)
Modified main 'pandoc' program so that if it is called with program
name = 'hsmarkdown' (e.g. through a symlink, on a system with real symbolic links), it will translate markdown to HTML in strict mode and interpret all command-line options as arguments, like Markdown.pl. git-svn-id: https://pandoc.googlecode.com/svn/trunk@405 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 3476a950b..534d99c95 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -342,7 +342,12 @@ defaultWriterName x =
main = do
args <- getArgs
- let (actions, sources, errors) = getOpt Permute options args
+ prg <- getProgName
+ let compatMode = (prg == "hsmarkdown")
+
+ let (actions, sources, errors) = if compatMode
+ then ([], args, [])
+ else getOpt Permute options args
if (not (null errors))
then do
@@ -353,8 +358,14 @@ main = do
else
return ()
+ let defaultOpts' = if compatMode
+ then defaultOpts { optReader = "markdown"
+ , optWriter = "html"
+ , optStrict = True }
+ else defaultOpts
+
-- thread option data structure through all supplied option actions
- opts <- foldl (>>=) (return defaultOpts) actions
+ opts <- foldl (>>=) (return defaultOpts') actions
let Opt { optPreserveTabs = preserveTabs
, optTabStop = tabStop
@@ -408,11 +419,11 @@ main = do
let addBlank str = str ++ "\n\n"
let removeCRs str = filter (/= '\r') str -- remove DOS-style line endings
let filter = tabFilter . addBlank . removeCRs
- let startParserState = defaultParserState { stateParseRaw = parseRaw,
- stateTabStop = tabStop,
- stateStandalone = standalone &&
- (not strict),
- stateStrict = strict }
+ let startParserState =
+ defaultParserState { stateParseRaw = parseRaw,
+ stateTabStop = tabStop,
+ stateStandalone = standalone && (not strict),
+ stateStrict = strict }
let csslink = if (css == "")
then ""
else "<link rel=\"stylesheet\" href=\"" ++ css ++