git.iko.soy/typeable/pandoc
on master help sign in
Small tweaks to hyphenatedurl patch.

Use isURI instead of isAbsoluteURI, as it also matches absolute URIs with '#...' at the end.

commit352ee2dc4f193bf1919723266016286feb0d985a authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 30 Dec 2011, 11:08 (15 years ago) parent80ba468
1 file changed+6−9
src/Text/Pandoc/Writers/ConTeXt.hs+6−9
src/Text/Pandoc/Writers/ConTeXt.hs+6−9
@@ -37,7 +37,7 @@ import Data.List ( intercalate )
3737import Control.Monad.State
3838import Text.Pandoc.Pretty
3939import Text.Pandoc.Templates ( renderTemplate )
40−import Network.URI ( isAbsoluteURI, unEscapeString )
40+import Network.URI ( isURI, unEscapeString )
4141
4242data WriterState =
4343 WriterState { stNextRef :: Int -- number of next URL reference
@@ -279,20 +279,17 @@ inlineToConTeXt (Link txt (src, _)) = do
279279 st <- get
280280 let next = stNextRef st
281281 put $ st {stNextRef = next + 1}
282− let ref ="urlref" ++ (show next)
283− let hyphenateURL x =
284− case x of
285− (Str str) -> if isAbsoluteURI str
286− then (RawInline "context" ("\\hyphenatedurl{" ++ str ++ "}"))
287− else x
288− _otherwise -> x
282+ let ref = "url" ++ show next
283+ let hyphenateURL (Str str) | isURI str =
284+ RawInline "context" ("\\hyphenatedurl{" ++ str ++ "}")
285+ hyphenateURL x = x
289286 label <- inlineListToConTeXt (bottomUp hyphenateURL $ normalize txt)
290287 return $ "\\useURL" <> brackets (text ref) <>
291288 brackets (text $ escapeStringUsing [('#',"\\#")] src) <>
292289 brackets empty <> brackets label <>
293290 "\\from" <> brackets (text ref)
294291inlineToConTeXt (Image _ (src, _)) = do
295− let src' = if isAbsoluteURI src
292+ let src' = if isURI src
296293 then src
297294 else unEscapeString src
298295 return $ braces $ "\\externalfigure" <> brackets (text src')