From 78475498b4d9ffc1677eff55667eb87108333544 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 5 Dec 2009 17:56:02 +0000 Subject: Added --id-prefix option. This adds a prefix to all automatically generated HTML identifiers, which helps prevent duplicate identifiers when you're generating a fragment (say a blog post). Added writerIdentifierPrefix to WriterOptions. Resolves Issue #41. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1650 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/pandoc.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/pandoc.hs') diff --git a/src/pandoc.hs b/src/pandoc.hs index e24d621bf..c2cc9b75e 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -153,6 +153,7 @@ data Opt = Opt , optSanitizeHTML :: Bool -- ^ Sanitize HTML , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply , optEmailObfuscation :: ObfuscationMethod + , optIdentifierPrefix :: String , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks #ifdef _CITEPROC , optBiblioFile :: String @@ -190,6 +191,7 @@ defaultOpts = Opt , optSanitizeHTML = False , optPlugins = [] , optEmailObfuscation = JavascriptObfuscation + , optIdentifierPrefix = "" , optIndentedCodeClasses = [] #ifdef _CITEPROC , optBiblioFile = [] @@ -314,6 +316,12 @@ options = "none|javascript|references") "" -- "Method for obfuscating email in HTML" + , Option "" ["id-prefix"] + (ReqArg + (\arg opt -> return opt { optIdentifierPrefix = arg }) + "STRING") + "" -- "Prefix to add to automatically generated HTML identifiers" + , Option "" ["indented-code-classes"] (ReqArg (\arg opt -> return opt { optIndentedCodeClasses = words $ @@ -540,6 +548,7 @@ main = do , optWrapText = wrap , optSanitizeHTML = sanitize , optEmailObfuscation = obfuscationMethod + , optIdentifierPrefix = idPrefix , optIndentedCodeClasses = codeBlockClasses #ifdef _CITEPROC , optBiblioFile = biblioFile @@ -627,7 +636,8 @@ main = do lhsExtension [outputFile], writerEmailObfuscation = if strict then ReferenceObfuscation - else obfuscationMethod } + else obfuscationMethod, + writerIdentifierPrefix = idPrefix } when (isNonTextOutput writerName' && outputFile == "-") $ do hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++ -- cgit v1.2.3