diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-10 22:38:07 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-10 22:39:47 -0800 |
commit | f8db21fa16e8f8e3244f4d3fc85ea1df17aae86f (patch) | |
tree | 0c374667b4fd18fc9dadf079a839fb3bdf6f1452 | |
parent | 23ab5ffcb0b708e4f07cafd7a877926ce0dc532b (diff) | |
download | pandoc-f8db21fa16e8f8e3244f4d3fc85ea1df17aae86f.tar.gz |
Options: Added phpMarkdownExtraExtensions.
And added markdown_phpextra input/output format.
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | pandoc.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc.hs | 20 | ||||
-rw-r--r-- | src/Text/Pandoc/Options.hs | 14 |
4 files changed, 28 insertions, 15 deletions
@@ -140,6 +140,7 @@ General options : Specify input format. *FORMAT* can be `native` (native Haskell), `json` (JSON version of native AST), `markdown` (pandoc's extended markdown), `markdown_strict` (original unextended markdown), + `markdown_phpextra` (PHP Markdown Extra extended markdown), `textile` (Textile), `rst` (reStructuredText), `html` (HTML), `docbook` (DocBook XML), `mediawiki` (MediaWiki markup), or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`, @@ -158,7 +159,8 @@ General options : Specify output format. *FORMAT* can be `native` (native Haskell), `json` (JSON version of native AST), `plain` (plain text), `markdown` (pandoc's extended markdown), `markdown_strict` (original - unextended markdown), `rst` (reStructuredText), `html` (XHTML + unextended markdown), `markdown_phpextra` (PHP Markdown extra + extended markdown), `rst` (reStructuredText), `html` (XHTML 1), `html5` (HTML 5), `latex` (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo), @@ -703,11 +703,6 @@ options = ] -readExtension :: String -> IO Extension -readExtension s = case safeRead ('E':'x':'t':'_':map toLower s) of - Just ext -> return ext - Nothing -> err 59 $ "Unknown extension: " ++ s - -- Returns usage message usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String usageMessage programName = usageInfo diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 91fbe0893..c942b037c 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -174,19 +174,20 @@ parseFormatSpec = parse formatSpec "" '-' -> Set.delete ext _ -> Set.insert ext +-- auxiliary function for readers: +markdown :: ReaderOptions -> String -> IO Pandoc +markdown o s = do + let (doc, warnings) = readMarkdownWithWarnings o s + mapM_ warn warnings + return doc + -- | Association list of formats and readers. readers :: [(String, ReaderOptions -> String -> IO Pandoc)] readers = [("native" , \_ s -> return $ readNative s) ,("json" , \_ s -> return $ decodeJSON s) - ,("markdown_strict" , \o s -> do - let (doc, warnings) = readMarkdownWithWarnings - o{ readerExtensions = strictExtensions } s - mapM_ warn warnings - return doc) - ,("markdown" , \o s -> do - let (doc, warnings) = readMarkdownWithWarnings o s - mapM_ warn warnings - return doc) + ,("markdown" , markdown) + ,("markdown_strict" , markdown) + ,("markdown_phpextra" , markdown) ,("rst" , \o s -> return $ readRST o s) ,("mediawiki" , \o s -> return $ readMediaWiki o s) ,("docbook" , \o s -> return $ readDocBook o s) @@ -245,6 +246,7 @@ writers = [ getDefaultExtensions :: String -> Set Extension getDefaultExtensions "markdown_strict" = strictExtensions +getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions getDefaultExtensions _ = pandocExtensions -- | Retrieve reader based on formatSpec (format+extensions). diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index b62187bfe..2382bb3e8 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -31,6 +31,7 @@ options. module Text.Pandoc.Options ( Extension(..) , pandocExtensions , strictExtensions + , phpMarkdownExtraExtensions , ReaderOptions(..) , HTMLMathMethod (..) , CiteMethod (..) @@ -134,6 +135,19 @@ pandocExtensions = Set.fromList , Ext_implicit_header_references ] +phpMarkdownExtraExtensions :: Set Extension +phpMarkdownExtraExtensions = Set.fromList + [ Ext_footnotes + , Ext_pipe_tables + , Ext_raw_html + , Ext_markdown_attribute + , Ext_fenced_code_blocks + , Ext_definition_lists + , Ext_intraword_underscores + , Ext_header_attributes + , Ext_abbreviations + ] + strictExtensions :: Set Extension strictExtensions = Set.fromList [ Ext_raw_html ] |