diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-30 11:08:42 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-30 11:08:42 -0800 |
commit | 352ee2dc4f193bf1919723266016286feb0d985a (patch) | |
tree | 3260f631383fbed081c6847151ef9ac50b2a145e /src/Text | |
parent | 80ba468535a535cd3545453c18fd5bc4e4f7e5b5 (diff) | |
download | pandoc-352ee2dc4f193bf1919723266016286feb0d985a.tar.gz |
Small tweaks to hyphenatedurl patch.
Use isURI instead of isAbsoluteURI, as it also matches
absolute URIs with '#...' at the end.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 15 |
1 files changed, 6 insertions, 9 deletions
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') |