packages feed

pandoc 1.5.0.1 → 1.5.1

raw patch · 32 files changed

+204/−151 lines, 32 filessetup-changedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Text.Pandoc.Shared: escapeURI :: String -> String
+ Text.Pandoc.Shared: unescapeURI :: String -> String
+ Text.Pandoc.Writers.OpenDocument: instance Ord TextStyle
- Text.Pandoc.Shared: emailAddress :: GenParser Char st [Char]
+ Text.Pandoc.Shared: emailAddress :: GenParser Char st (String, String)
- Text.Pandoc.Shared: uri :: GenParser Char st String
+ Text.Pandoc.Shared: uri :: GenParser Char st (String, String)

Files

@@ -1,5 +1,5 @@ Pandoc-Copyright (C) 2006-8 John MacFarlane <jgm at berkeley dot edu>+Copyright (C) 2006-2010 John MacFarlane <jgm at berkeley dot edu>  This code is released under the [GPL], version 2 or later: @@ -32,25 +32,25 @@ licenses.  -----------------------------------------------------------------------Text/Pandoc/Writers/Texinfo.hs-Copyright (C) 2008 John MacFarlane and Peter Wang+src/Text/Pandoc/Writers/Texinfo.hs+Copyright (C) 2008-2010 John MacFarlane and Peter Wang  Released under the GPL.  -----------------------------------------------------------------------Text/Pandoc/Writers/OpenDocument.hs-Copyright (C) 2008 Andrea Rossato+src/Text/Pandoc/Writers/OpenDocument.hs+Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane  Released under the GPL.  -----------------------------------------------------------------------Text/Pandoc/Biblio.hs+src/Text/Pandoc/Biblio.hs Copyright (C) 2008 Andrea Rossato  Released under the GPL.  -----------------------------------------------------------------------LaTeXMathML.js+data/LaTeXMathML.js Adapted by Jeff Knisely and Douglas Woodall from ASCIIMathML.js v. 1.4.7 Copyright (C) 2005 Peter Jipsen@@ -58,18 +58,20 @@ Released under the GPL.  -----------------------------------------------------------------------S5 slides.js and css files +data/MathMLInHTML.js+Copyright (C) 2004 Peter Jipsen http://www.chapman.edu/~jipsen++Released under the GNU General Public License version 2 or later.+See the GNU General Public License+(at http://www.gnu.org/copyleft/gpl.html) for more details.++----------------------------------------------------------------------+s5/default+S5 slides.js and css files by Eric A. Meyer <http://meyerweb.com/eric/tools/s5  Released under an explicit Public Domain License---------------------------------------------------------------------------Diff.hs in tests/-from the Diff package v 0.1.2 (Data.Algorithm.Diff)-Copyright (c) Sterling Clover 2008--Released under 3 clause BSD license.  ------------------------------------------------------------------------ windows/modpath.iss
Setup.hs view
@@ -48,7 +48,9 @@  -- | Build man pages from markdown sources in man/man1/. makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()-makeManPages _ flags _ _ = mapM_ (makeManPage (fromFlag $ buildVerbosity flags)) manpages+makeManPages _ flags _ buildInfo =+  mapM_ (makeManPage pandocPath (fromFlag $ buildVerbosity flags)) manpages+    where pandocPath = (buildDir buildInfo) </> "pandoc" </> "pandoc"  manpages :: [FilePath] manpages = ["pandoc.1", "markdown2pdf.1"]@@ -57,21 +59,20 @@ manDir = "man" </> "man1"  -- | Build a man page from markdown source in man/man1.-makeManPage :: Verbosity -> FilePath -> IO ()-makeManPage verbosity manpage = do-  let pandoc = "dist" </> "build" </> "pandoc" </> "pandoc"+makeManPage :: FilePath -> Verbosity -> FilePath -> IO ()+makeManPage pandoc verbosity manpage = do   let page = manDir </> manpage-  let source = manDir </> manpage <.> "md"+  let source = page <.> "md"   modifiedDeps <- modifiedDependencies page [source]   unless (null modifiedDeps) $ do     ec <- runProcess pandoc ["-s", "-S", "-r", "markdown", "-w", "man",                 "--template=templates/man.template", "-o", page, source]                 Nothing Nothing Nothing Nothing (Just stderr) >>= waitForProcess     case ec of-         ExitSuccess -> unless (verbosity == silent) $-                           putStrLn $ "Created " ++ manDir </> manpage-         _           -> do putStrLn $ "Error creating " ++ manDir </> manpage-                           exitWith ec+         ExitSuccess   -> unless (verbosity == silent) $+                             putStrLn $ "Created " ++ page+         ExitFailure n -> putStrLn ("Error creating " ++ page +++                             ". Exit code = " ++ show n) >> exitWith ec  installScripts :: PackageDescription -> LocalBuildInfo                -> Verbosity -> CopyDest -> IO ()
changelog view
@@ -1,3 +1,26 @@+pandoc (1.5.1)++  [ John MacFarlane ]++  * Fixed treatment of unicode characters in URIs.+    + Shared now exports escapeURI and unescapeURI. These handle+      UTF8 encoding and decoding as well as URI escaping/unescaping.+    + Shared: uri and emailAddress now return a pair of the original+      parsed text and the escaped URI (in the latter case, with+      the mailto: prefix).+    + HTML reader: unsanitaryURI has been modified to allow unicode+		  high characters in a URI.+    + Readers:  All link and image URIs are now escaped using+		  escapeURI.+    + Markdown and RST writers:  unescapeURI is used so that URIs+      in these formats are human-readable.++  * Setup.hs: Don't assume that the build directory is "dist".+    Instead, get it from localBuildInfo.++  * OpenDocument writer: Use a Map for stTextStyleAttr.+    This avoids duplicates (and invalid xml). Resolves Issue #222.+ pandoc (1.5.0.1)    [ John MacFarlane ]
man/man1/pandoc.1.md view
@@ -351,8 +351,6 @@  # SEE ALSO -`hsmarkdown`(1),-`html2markdown`(1), `markdown2pdf` (1). The *README* file distributed with Pandoc contains full documentation. 
pandoc.cabal view
@@ -1,5 +1,5 @@ Name:            pandoc-Version:         1.5.0.1+Version:         1.5.1 Cabal-Version:   >= 1.2 Build-Type:      Custom License:         GPL
src/Text/Pandoc.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/CharacterReferences.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.CharacterReferences-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Definition.hs view
@@ -1,6 +1,6 @@ {-# OPTIONS_GHC -fglasgow-exts #-} -- for deriving Typeable {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -19,7 +19,7 @@  {- |    Module      : Text.Pandoc.Definition-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/ODT.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.ODT-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2008-2010 John MacFarlane    License     : GNU GPL, version 2 or above     Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Readers/HTML.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Readers.HTML-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -182,7 +182,7 @@              "ldaps:", "magnet:", "mms:", "msnim:", "notes:", "rsync:",              "secondlife:", "skype:", "ssh:", "sftp:", "smb:", "sms:",              "snews:", "webcal:", "ymsgr:"]-  in  case parseURIReference u of+  in  case parseURIReference (escapeURI u) of            Just p  -> (map toLower $ uriScheme p) `notElem` safeURISchemes            Nothing -> True @@ -746,7 +746,7 @@            Nothing  -> fail "no href"   let title = fromMaybe "" $ extractAttribute "title" attributes   lab <- inlinesTilEnd "a"-  return $ Link (normalizeSpaces lab) (url, title)+  return $ Link (normalizeSpaces lab) (escapeURI url, title)  image :: GenParser Char ParserState Inline image = try $ do@@ -756,5 +756,5 @@            Nothing  -> fail "no src"   let title = fromMaybe "" $ extractAttribute "title" attributes   let alt = fromMaybe "" (extractAttribute "alt" attributes)-  return $ Image [Str alt] (url, title)+  return $ Image [Str alt] (escapeURI url, title) 
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Readers.LaTeX-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -738,7 +738,7 @@ url = try $ do   string "\\url"   url' <- charsInBalanced '{' '}'-  return $ Link [Code url'] (url', "")+  return $ Link [Code url'] (escapeURI url', "")  link :: GenParser Char ParserState Inline link = try $ do@@ -746,17 +746,16 @@   url' <- manyTill anyChar (char '}')   char '{'   label' <- manyTill inline (char '}') -  return $ Link (normalizeSpaces label') (url', "")+  return $ Link (normalizeSpaces label') (escapeURI url', "")  image :: GenParser Char ParserState Inline image = try $ do   ("includegraphics", _, args) <- command   let args' = filter isArg args -- filter out options-  let src = if null args' then-              ("", "")-            else-              (stripFirstAndLast (head args'), "")-  return $ Image [Str "image"] src+  let (src,tit) = case args' of+                       []    -> ("", "")+                       (x:_) -> (stripFirstAndLast x, "")+  return $ Image [Str "image"] (escapeURI src, tit)  footnote :: GenParser Char ParserState Inline footnote = try $ do
src/Text/Pandoc/Readers/Markdown.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Readers.Markdown-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -31,7 +31,7 @@                                      readMarkdown                                      ) where -import Data.List ( transpose, isPrefixOf, isSuffixOf, sortBy, findIndex, intercalate )+import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate ) import Data.Ord ( comparing ) import Data.Char ( isAlphaNum ) import Data.Maybe@@ -73,10 +73,6 @@ -- auxiliary functions -- --- | Replace spaces with %20-uriEscapeSpaces :: String -> String-uriEscapeSpaces = substitute " " "%20"- indentSpaces :: GenParser Char ParserState [Char] indentSpaces = try $ do   state <- getState@@ -206,7 +202,7 @@   tit <- option "" referenceTitle   blanklines   endPos <- getPosition-  let newkey = (lab, (uriEscapeSpaces $ removeTrailingSpace src,  tit))+  let newkey = (lab, (escapeURI $ removeTrailingSpace src,  tit))   st <- getState   let oldkeys = stateKeys st   updateState $ \s -> s { stateKeys = newkey : oldkeys }@@ -1194,7 +1190,7 @@   tit <- option "" linkTitle   skipSpaces   eof-  return (uriEscapeSpaces $ removeTrailingSpace src, tit)+  return (escapeURI $ removeTrailingSpace src, tit)  linkTitle :: GenParser Char st String linkTitle = try $ do @@ -1208,11 +1204,11 @@ link :: GenParser Char ParserState Inline link = try $ do   lab <- reference-  src <- source <|> referenceLink lab+  (src, tit) <- source <|> referenceLink lab   sanitize <- getState >>= return . stateSanitizeHTML-  if sanitize && unsanitaryURI (fst src)+  if sanitize && unsanitaryURI src      then fail "Unsanitary URI"-     else return $ Link lab src+     else return $ Link lab (src, tit)  -- a link like [this][ref] or [this][] or [this] referenceLink :: [Inline]@@ -1229,18 +1225,15 @@ autoLink :: GenParser Char ParserState Inline autoLink = try $ do   char '<'-  src <- uri <|> (emailAddress >>= (return . ("mailto:" ++)))+  (orig, src) <- uri <|> emailAddress   char '>'-  let src' = if "mailto:" `isPrefixOf` src-                then drop 7 src-                else src    st <- getState   let sanitize = stateSanitizeHTML st   if sanitize && unsanitaryURI src      then fail "Unsanitary URI"      else return $ if stateStrict st-                      then Link [Str src'] (src, "")-                      else Link [Code src'] (src, "")+                      then Link [Str orig] (src, "")+                      else Link [Code orig] (src, "")  image :: GenParser Char ParserState Inline image = try $ do
src/Text/Pandoc/Readers/RST.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Readers.RST -   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -556,7 +556,7 @@   contents <- many1 (try (many spaceChar >> newline >>                            many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")   blanklines-  return contents+  return $ escapeURI $ removeLeadingTrailingSpace $ contents  imageKey :: GenParser Char ParserState ([Inline], (String, [Char])) imageKey = try $ do@@ -565,13 +565,13 @@   skipSpaces   string "image::"   src <- targetURI-  return (normalizeSpaces ref, (removeLeadingTrailingSpace src, ""))+  return (normalizeSpaces ref, (src, ""))  anonymousKey :: GenParser Char st ([Inline], (String, [Char])) anonymousKey = try $ do   oneOfStrings [".. __:", "__"]   src <- targetURI-  return ([Str "_"], (removeLeadingTrailingSpace src, ""))+  return ([Str "_"], (src, ""))  regularKey :: GenParser Char ParserState ([Inline], (String, [Char])) regularKey = try $ do@@ -579,7 +579,7 @@   ref <- referenceName   char ':'   src <- targetURI-  return (normalizeSpaces ref, (removeLeadingTrailingSpace src, ""))+  return (normalizeSpaces ref, (src, ""))  -- -- tables@@ -883,7 +883,8 @@   src <- manyTill (noneOf ">\n") (char '>')   skipSpaces   string "`_"-  return $ Link (normalizeSpaces label') (removeLeadingTrailingSpace src, "")+  return $ Link (normalizeSpaces label')+            (escapeURI $ removeLeadingTrailingSpace src, "")  referenceLink :: GenParser Char ParserState Inline referenceLink = try $ do@@ -891,25 +892,25 @@   key <- option label' (do{char '_'; return [Str "_"]}) -- anonymous link   state <- getState   let keyTable = stateKeys state-  src <- case lookupKeySrc keyTable key of-           Nothing     -> fail "no corresponding key"-           Just target -> return target+  (src,tit) <- case lookupKeySrc keyTable key of+                    Nothing     -> fail "no corresponding key"+                    Just target -> return target   -- if anonymous link, remove first anon key so it won't be used again   let keyTable' = if (key == [Str "_"]) -- anonymous link? -                    then delete ([Str "_"], src) keyTable -- remove first anon key +                    then delete ([Str "_"], (src,tit)) keyTable -- remove first anon key                      else keyTable                       setState $ state { stateKeys = keyTable' }-  return $ Link (normalizeSpaces label') src +  return $ Link (normalizeSpaces label') (src, tit)   autoURI :: GenParser Char ParserState Inline autoURI = do-  src <- uri-  return $ Link [Str src] (src, "")+  (orig, src) <- uri+  return $ Link [Str orig] (src, "")  autoEmail :: GenParser Char ParserState Inline autoEmail = do-  src <- emailAddress-  return $ Link [Str src] ("mailto:" ++ src, "")+  (orig, src) <- emailAddress+  return $ Link [Str orig] (src, "")  autoLink :: GenParser Char ParserState Inline autoLink = autoURI <|> autoEmail@@ -921,7 +922,7 @@   ref <- manyTill inline (char '|')   state <- getState   let keyTable = stateKeys state-  src <- case lookupKeySrc keyTable ref of-           Nothing     -> fail "no corresponding key"-           Just target -> return target-  return $ Image (normalizeSpaces ref) src+  (src,tit) <- case lookupKeySrc keyTable ref of+                     Nothing     -> fail "no corresponding key"+                     Just target -> return target+  return $ Image (normalizeSpaces ref) (src, tit)
src/Text/Pandoc/Readers/TeXMath.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2007 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Readers.TeXMath-   Copyright   : Copyright (C) 2007 John MacFarlane+   Copyright   : Copyright (C) 2007-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Shared.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE DeriveDataTypeable #-} {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -19,7 +19,7 @@  {- |    Module      : Text.Pandoc.Shared-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -28,7 +28,7 @@  Utility functions and definitions used by the various Pandoc modules. -}-module Text.Pandoc.Shared ( +module Text.Pandoc.Shared (                      -- * List processing                      splitBy,                      splitByIndices,@@ -43,6 +43,8 @@                      stripFirstAndLast,                      camelCaseToHyphenated,                      toRomanNumeral,+                     escapeURI,+                     unescapeURI,                      wrapped,                      wrapIfNeeded,                      wrappedTeX,@@ -114,10 +116,11 @@ import Text.PrettyPrint.HughesPJ ( Doc, fsep, ($$), (<>), empty, isEmpty, text, nest ) import qualified Text.PrettyPrint.HughesPJ as PP import Text.Pandoc.CharacterReferences ( characterReference )-import Data.Char ( toLower, toUpper, ord, isLower, isUpper, isAlpha,+import Data.Char ( toLower, toUpper, ord, isLower, isUpper, isAlpha, isAscii,                    isPunctuation ) import Data.List ( find, isPrefixOf, intercalate )-import Network.URI ( parseURI, URI (..), isAllowedInURI )+import Network.URI ( parseURI, URI (..), isAllowedInURI, escapeURIString, unEscapeString )+import Codec.Binary.UTF8.String ( encodeString, decodeString ) import System.Directory import System.FilePath ( (</>) ) -- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv@@ -131,6 +134,7 @@ import qualified Control.Monad.State as S import Control.Monad (join) import Paths_pandoc (getDataFileName)+ -- -- List processing --@@ -228,6 +232,17 @@               _ | x >= 1    -> "I" ++ toRomanNumeral (x - 1)               _             -> "" +-- | Escape unicode characters in a URI.  Characters that are+-- already valid in a URI, including % and ?, are left alone.+escapeURI :: String -> String+escapeURI = escapeURIString isAllowedInURI . encodeString++-- | Unescape unicode and some special characters in a URI, but+-- without introducing spaces.+unescapeURI :: String -> String+unescapeURI = escapeURIString (\c -> isAllowedInURI c || not (isAscii c)) .+               decodeString . unEscapeString+ -- | Wrap inlines to line length. wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>= @@ -479,25 +494,30 @@   dom <- many1 $ try (char '.' >> many1 domainChar )   return $ intercalate "." (first:dom) --- | Parses an email address; returns string.-emailAddress :: GenParser Char st [Char]+-- | Parses an email address; returns original and corresponding+-- escaped mailto: URI.+emailAddress :: GenParser Char st (String, String) emailAddress = try $ do   firstLetter <- alphaNum   restAddr <- many emailChar   let addr = firstLetter:restAddr   char '@'   dom <- domain-  return $ addr ++ '@':dom+  let full = addr ++ '@':dom+  return (full, escapeURI $ "mailto:" ++ full) --- | Parses a URI.-uri :: GenParser Char st String+-- | Parses a URI. Returns pair of original and URI-escaped version.+uri :: GenParser Char st (String, String) uri = try $ do-  str <- many1 $ satisfy isAllowedInURI-  case parseURI str of-       Just uri' -> if uriScheme uri' `elem` [ "http:", "https:", "ftp:",-                                               "file:", "mailto:",-                                               "news:", "telnet:" ]-                       then return $ show uri'+  let protocols = [ "http:", "https:", "ftp:", "file:", "mailto:",+                    "news:", "telnet:" ]+  lookAhead $ oneOfStrings protocols+  -- scan non-ascii characters and ascii characters allowed in a URI+  str <- many1 $ satisfy (\c -> not (isAscii c) || isAllowedInURI c)+  -- now see if they amount to an absolute URI+  case parseURI (escapeURI str) of+       Just uri' -> if uriScheme uri' `elem` protocols+                       then return (str, show uri')                        else fail "not a URI"        Nothing   -> fail "not a URI" 
src/Text/Pandoc/Templates.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE TypeSynonymInstances #-} {--Copyright (C) 2009 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2009-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -19,7 +19,7 @@  {- |    Module      : Text.Pandoc.Templates-   Copyright   : Copyright (C) 2009 John MacFarlane+   Copyright   : Copyright (C) 2009-2010 John MacFarlane    License     : GNU GPL, version 2 or above     Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/ConTeXt.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2007-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.ConTeXt-   Copyright   : Copyright (C) 2007-8 John MacFarlane+   Copyright   : Copyright (C) 2007-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/Docbook.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.Docbook-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/HTML.hs view
@@ -1,6 +1,6 @@ {-# OPTIONS_GHC -fno-warn-deprecations #-} {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -19,7 +19,7 @@  {- |    Module      : Text.Pandoc.Writers.HTML -   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/LaTeX.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.LaTeX-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/Man.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2007 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.Man -   Copyright   : Copyright (C) 2007 John MacFarlane+   Copyright   : Copyright (C) 2007-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/Markdown.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.Markdown -   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -400,9 +400,10 @@ inlineToMarkdown _ (LineBreak) = return $ text "  \n" inlineToMarkdown _ Space = return $ char ' ' inlineToMarkdown opts (Cite _ cits) = inlineListToMarkdown opts cits-inlineToMarkdown opts (Link txt (src, tit)) = do+inlineToMarkdown opts (Link txt (src', tit)) = do   linktext <- inlineListToMarkdown opts txt   let linktitle = if null tit then empty else text $ " \"" ++ tit ++ "\""+  let src = unescapeURI src'   let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src   let useRefLinks = writerReferenceLinks opts   let useAuto = null tit && txt == [Code srcSuffix]@@ -423,7 +424,7 @@                (alternate == [Str source]) -- to prevent autolinks                then [Str "image"]                else alternate-  linkPart <- inlineToMarkdown opts (Link txt (source, tit)) +  linkPart <- inlineToMarkdown opts (Link txt (unescapeURI source, tit))    return $ char '!' <> linkPart inlineToMarkdown _ (Note contents) = do    modify (\st -> st{ stNotes = contents : stNotes st })
src/Text/Pandoc/Writers/MediaWiki.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.MediaWiki -   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2008-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/OpenDocument.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE PatternGuards #-} {--Copyright (C) 2008 Andrea Rossato <andrea.rossato@ing.unitn.it>+Copyright (C) 2008-2010 Andrea Rossato <andrea.rossato@ing.unitn.it>+and John MacFarlane.  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -19,7 +20,7 @@  {- |    Module      : Text.Pandoc.Writers.OpenDocument-   Copyright   : Copyright (C) 2008 Andrea Rossato+   Copyright   : Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane    License     : GNU GPL, version 2 or above     Maintainer  : Andrea Rossato <andrea.rossato@ing.unitn.it>@@ -40,6 +41,7 @@ import Control.Arrow ( (***), (>>>) ) import Control.Monad.State hiding ( when ) import Data.Char (chr)+import qualified Data.Map as Map  -- | Auxiliary function to convert Plain block to Para. plainToPara :: Block -> Block@@ -56,7 +58,7 @@                 , stParaStyles    :: [Doc]                 , stListStyles    :: [(Int, [Doc])]                 , stTextStyles    :: [Doc]-                , stTextStyleAttr :: [(TextStyle,[(String,String)])]+                , stTextStyleAttr :: Map.Map TextStyle [(String,String)]                 , stIndentPara    :: Int                 , stInDefinition  :: Bool                 , stTight         :: Bool@@ -69,7 +71,7 @@                 , stParaStyles    = []                 , stListStyles    = []                 , stTextStyles    = []-                , stTextStyleAttr = []+                , stTextStyleAttr = Map.empty                 , stIndentPara    = 0                 , stInDefinition  = False                 , stTight         = False@@ -91,11 +93,10 @@ addTextStyle i = modify $ \s -> s { stTextStyles = i : stTextStyles s }  addTextStyleAttr :: (TextStyle, [(String,String)]) -> State WriterState ()-addTextStyleAttr i = modify $ \s -> s { stTextStyleAttr = i : stTextStyleAttr s }+addTextStyleAttr (ts, xs) = modify $ \s -> s { stTextStyleAttr = Map.insert ts xs (stTextStyleAttr s) } -rmTextStyleAttr :: State WriterState ()-rmTextStyleAttr = modify $ \s -> s { stTextStyleAttr = rmHead (stTextStyleAttr s) }-    where rmHead l = if l /= [] then tail l else []+rmTextStyleAttr :: TextStyle -> State WriterState ()+rmTextStyleAttr ts = modify $ \s -> s { stTextStyleAttr = Map.delete ts (stTextStyleAttr s) }  increaseIndent :: State WriterState () increaseIndent = modify $ \s -> s { stIndentPara = 1 + stIndentPara s }@@ -121,18 +122,18 @@  withTextStyle :: TextStyle -> State WriterState a -> State WriterState a withTextStyle s f = addTextStyleAttr (s,textStyleAttr s) >>-                    f >>= \r -> rmTextStyleAttr >> return r+                    f >>= \r -> rmTextStyleAttr s >> return r  inTextStyle :: Doc -> State WriterState Doc inTextStyle d = do   at <- gets stTextStyleAttr-  if at == []+  if Map.null at      then return d      else do        tn <- (+) 1 . length  <$> gets stTextStyles        addTextStyle $ inTags False "style:style" [("style:name"  , "T" ++ show tn)                                                  ,("style:family", "text"        )]-                    $ selfClosingTag "style:text-properties" (concatMap snd at)+                    $ selfClosingTag "style:text-properties" (concatMap snd $ Map.toList at)        return $ inTags False "text:span" [("text:style-name","T" ++ show tn)] d  inHeaderTags :: Int -> Doc -> Doc@@ -491,7 +492,7 @@                      [ ("fo:text-align", x)                      , ("style:justify-single-word", "false")] -data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq )+data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq,Ord )  textStyleAttr :: TextStyle -> [(String,String)] textStyleAttr s
src/Text/Pandoc/Writers/RST.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.RST -   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>@@ -305,8 +305,9 @@ inlineToRST (Link [Code str] (src, _)) | src == str ||                                          src == "mailto:" ++ str = do   let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src-  return $ text srcSuffix-inlineToRST (Link txt (src, tit)) = do+  return $ text $ unescapeURI srcSuffix+inlineToRST (Link txt (src', tit)) = do+  let src = unescapeURI src'   useReferenceLinks <- get >>= (return . writerReferenceLinks . stOptions)   linktext <- inlineListToRST $ normalizeSpaces txt   if useReferenceLinks@@ -317,7 +318,8 @@             modify $ \st -> st { stLinks = refs' }             return $ char '`' <> linktext <> text "`_"     else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_"-inlineToRST (Image alternate (source, tit)) = do+inlineToRST (Image alternate (source', tit)) = do+  let source = unescapeURI source'   pics <- get >>= (return . stImages)   let labelsUsed = map fst pics    let txt = if null alternate || alternate == [Str ""] || 
src/Text/Pandoc/Writers/RTF.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.RTF-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/S5.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.S5-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/Writers/Texinfo.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2008 John MacFarlane and Peter Wang+Copyright (C) 2008-2010 John MacFarlane and Peter Wang  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.Writers.Texinfo-   Copyright   : Copyright (C) 2008 John MacFarlane and Peter Wang+   Copyright   : Copyright (C) 2008-2010 John MacFarlane and Peter Wang    License     : GNU GPL, version 2 or above      Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/Text/Pandoc/XML.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-7 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Text.Pandoc.XML-   Copyright   : Copyright (C) 2006-7 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above     Maintainer  : John MacFarlane <jgm@berkeley.edu>
src/pandoc.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@  {- |    Module      : Main-   Copyright   : Copyright (C) 2006-8 John MacFarlane+   Copyright   : Copyright (C) 2006-2010 John MacFarlane    License     : GNU GPL, version 2 or above     Maintainer  : John MacFarlane <jgm@berkeley@edu>
tests/markdown-reader-more.native view
@@ -27,5 +27,9 @@ , Para [Code "hi there"] , Para [Code "hi````there"] , Para [Str "`",Str "hi"]-, Para [Str "there",Str "`"] ]+, Para [Str "there",Str "`"]+, Header 2 [Str "Multilingual",Space,Str "URLs"]+, Para [Link [Code "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")]+, Para [Link [Str "foo"] ("/bar/%E6%B5%8B?x=%E6%B5%8B","title")]+, Para [Link [Code "\27979@foo.\27979.baz"] ("mailto:%E6%B5%8B@foo.%E6%B5%8B.baz","")] ] 
tests/markdown-reader-more.txt view
@@ -83,3 +83,11 @@  there` +## Multilingual URLs++<http://测.com?测=测>++[foo](/bar/测?x=测 "title")++<测@foo.测.baz>+