From 352ee2dc4f193bf1919723266016286feb0d985a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 30 Dec 2011 11:08:42 -0800 Subject: Small tweaks to hyphenatedurl patch. Use isURI instead of isAbsoluteURI, as it also matches absolute URIs with '#...' at the end. --- src/Text/Pandoc/Writers/ConTeXt.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 6333d44a1..ad27daffe 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -37,7 +37,7 @@ import Data.List ( intercalate ) import Control.Monad.State import Text.Pandoc.Pretty import Text.Pandoc.Templates ( renderTemplate ) -import Network.URI ( isAbsoluteURI, unEscapeString ) +import Network.URI ( isURI, unEscapeString ) data WriterState = WriterState { stNextRef :: Int -- number of next URL reference @@ -279,20 +279,17 @@ inlineToConTeXt (Link txt (src, _)) = do st <- get let next = stNextRef st put $ st {stNextRef = next + 1} - let ref ="urlref" ++ (show next) - let hyphenateURL x = - case x of - (Str str) -> if isAbsoluteURI str - then (RawInline "context" ("\\hyphenatedurl{" ++ str ++ "}")) - else x - _otherwise -> x + let ref = "url" ++ show next + let hyphenateURL (Str str) | isURI str = + RawInline "context" ("\\hyphenatedurl{" ++ str ++ "}") + hyphenateURL x = x label <- inlineListToConTeXt (bottomUp hyphenateURL $ normalize txt) return $ "\\useURL" <> brackets (text ref) <> brackets (text $ escapeStringUsing [('#',"\\#")] src) <> brackets empty <> brackets label <> "\\from" <> brackets (text ref) inlineToConTeXt (Image _ (src, _)) = do - let src' = if isAbsoluteURI src + let src' = if isURI src then src else unEscapeString src return $ braces $ "\\externalfigure" <> brackets (text src') -- cgit v1.2.3