diff options
author | B. Scott Michel <scooter.phd@gmail.com> | 2011-09-01 13:36:11 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-30 10:48:57 -0800 |
commit | 80ba468535a535cd3545453c18fd5bc4e4f7e5b5 (patch) | |
tree | 2b0dcd659e6b86d9f56e666b468a24b4b117592c /src | |
parent | b76ba44c52563806f89fbdb0d825e19c32dc9d36 (diff) | |
download | pandoc-80ba468535a535cd3545453c18fd5bc4e4f7e5b5.tar.gz |
ConTeXt_url_hyphenation
Deeply scan through the [Inline] associated with a Link and ensure that
all URLs are hyphenated using SYB primitives.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index a6771437d..6333d44a1 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -31,7 +31,7 @@ Conversion of 'Pandoc' format into ConTeXt. module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where import Text.Pandoc.Definition import Text.Pandoc.Shared -import Text.Pandoc.Generic (queryWith) +import Text.Pandoc.Generic (queryWith, bottomUp) import Text.Printf ( printf ) import Data.List ( intercalate ) import Control.Monad.State @@ -272,14 +272,21 @@ inlineToConTeXt (RawInline "tex" str) = return $ text str inlineToConTeXt (RawInline _ _) = return empty inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr inlineToConTeXt Space = return space -inlineToConTeXt (Link [Code _ str] (src, tit)) = -- since ConTeXt has its own - inlineToConTeXt (Link [Str str] (src, tit)) -- way of printing links... -inlineToConTeXt (Link txt (src, _)) = do +-- ConTeXT has its own way of printing links +inlineToConTeXt (Link [Code _ str] (src, tit)) = inlineToConTeXt (Link [Str str] (src, tit)) +-- Convert link's text, hyphenating URLs when they're seen (does deep list inspection) +inlineToConTeXt (Link txt (src, _)) = do st <- get let next = stNextRef st put $ st {stNextRef = next + 1} - let ref = show next - label <- inlineListToConTeXt txt + 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 + label <- inlineListToConTeXt (bottomUp hyphenateURL $ normalize txt) return $ "\\useURL" <> brackets (text ref) <> brackets (text $ escapeStringUsing [('#',"\\#")] src) <> brackets empty <> brackets label <> |