From 5fc6669be6823f19dd515f699c90101e919e2803 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 26 Jan 2012 23:55:37 -0800 Subject: [PATCH] Added --atx-headers option. --- README | 4 ++++ src/Text/Pandoc/Shared.hs | 2 ++ src/pandoc.hs | 12 +++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README b/README index a01297193..2e87a3116 100644 --- a/README +++ b/README @@ -342,6 +342,10 @@ Options affecting specific writers : Use reference-style links, rather than inline links, in writing markdown or reStructuredText. By default inline links are used. +`--atx-headers` +: Use ATX style headers in markdown output. The default is to use + setext-style headers for levels 1-2, and then ATX headers. + `--chapters` : Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook output. When the LaTeX template uses the report, book, or diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 8a4850ed3..7bb4b68e5 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -483,6 +483,7 @@ data WriterOptions = WriterOptions , writerListings :: Bool -- ^ Use listings package for code , writerHighlight :: Bool -- ^ Highlight source code , writerHighlightStyle :: Style -- ^ Style to use for highlighting + , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown } deriving Show {-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-} @@ -520,6 +521,7 @@ defaultWriterOptions = , writerListings = False , writerHighlight = False , writerHighlightStyle = pygments + , writerSetextHeaders = True } -- diff --git a/src/pandoc.hs b/src/pandoc.hs index a8f134e44..ecebe18f6 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -132,6 +132,7 @@ data Opt = Opt , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf , optBeamer :: Bool -- ^ Produce latex output for beamer class , optSlideLevel :: Maybe Int -- ^ Header level that creates slides + , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2 } -- | Defaults for command-line options. @@ -182,6 +183,7 @@ defaultOpts = Opt , optLaTeXEngine = "pdflatex" , optBeamer = False , optSlideLevel = Nothing + , optSetextHeaders = True } -- | A list of functions, each transforming the options data structure @@ -414,6 +416,11 @@ options = (\opt -> return opt { optReferenceLinks = True } )) "" -- "Use reference links in parsing HTML" + , Option "" ["atx-headers"] + (NoArg + (\opt -> return opt { optSetextHeaders = False } )) + "" -- "Use atx-style headers for markdown" + , Option "" ["chapters"] (NoArg (\opt -> return opt { optChapters = True })) @@ -810,6 +817,7 @@ main = do , optLaTeXEngine = latexEngine , optBeamer = beamer , optSlideLevel = slideLevel + , optSetextHeaders = setextHeaders } = opts when dumpArgs $ @@ -960,7 +968,9 @@ main = do writerBeamer = beamer, writerSlideLevel = slideLevel, writerHighlight = highlight, - writerHighlightStyle = highlightStyle } + writerHighlightStyle = highlightStyle, + writerSetextHeaders = setextHeaders + } when (writerName' `elem` nonTextFormats&& outputFile == "-") $ err 5 $ "Cannot write " ++ writerName' ++ " output to stdout.\n" ++