From 3811494e06613f472c28a00ec3de00b50490f143 Mon Sep 17 00:00:00 2001 From: Mark Lentczner Date: Thu, 15 Jul 2010 05:02:26 +0000 Subject: clean up of anchors --- src/Haddock/Backends/Xhtml/Names.hs | 5 +---- src/Haddock/Backends/Xhtml/Util.hs | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Haddock/Backends/Xhtml/Names.hs b/src/Haddock/Backends/Xhtml/Names.hs index 755b7a2d..5b3732c6 100644 --- a/src/Haddock/Backends/Xhtml/Names.hs +++ b/src/Haddock/Backends/Xhtml/Names.hs @@ -43,9 +43,6 @@ ppDocName (Documented name mdl) = where occName = nameOccName name ppDocName (Undocumented name) = toHtml (getOccString name) -linkTarget :: OccName -> Html -linkTarget n = namedAnchor (anchorNameStr n) << toHtml "" - ppName :: Name -> Html ppName name = toHtml (getOccString name) @@ -54,7 +51,7 @@ ppBinder :: Bool -> OccName -> Html -- The Bool indicates whether we are generating the summary, in which case -- the binder will be a link to the full definition. ppBinder True n = linkedAnchor (anchorNameStr n) << ppBinder' n -ppBinder False n = linkTarget n +++ bold << ppBinder' n +ppBinder False n = namedAnchor (anchorNameStr n) << bold << ppBinder' n ppBinder' :: OccName -> Html diff --git a/src/Haddock/Backends/Xhtml/Util.hs b/src/Haddock/Backends/Xhtml/Util.hs index 826b69f1..f2527b06 100644 --- a/src/Haddock/Backends/Xhtml/Util.hs +++ b/src/Haddock/Backends/Xhtml/Util.hs @@ -177,15 +177,21 @@ s8 = tda [ theclass "s8" ] << noHtml -- | Generate a named anchor -- --- This actually generates two anchor tags, one with the name unescaped, and one +-- This used to generate two anchor tags, one with the name unescaped, and one -- with the name URI-escaped. This is needed because Opera 9.52 (and later -- versions) needs the name to be unescaped, while IE 7 needs it to be escaped. --- -namedAnchor :: String -> Html -> Html -namedAnchor n c = anchor ! [Html.name n] << noHtml +++ - anchor ! [Html.name (escapeStr n)] << c +-- The escaped form for IE 7 is probably erroneous and not needed... +namedAnchor :: String -> Html -> Html +namedAnchor n c = anchor ! [Html.name n] << c +linkedAnchor :: String -> Html -> Html +linkedAnchor frag = anchor ! [href hr_] + where hr_ | null frag = "" + | otherwise = '#': escapeStr frag + -- this escape function is over-zealous for the fragment part of a URI + -- (':' for example does not need to be escaped) + -- -- A section of HTML which is collapsible via a +/- button. -- @@ -207,11 +213,6 @@ collapsed fn id_ html = collapseId :: Name -> String collapseId nm = "i:" ++ escapeStr (getOccString nm) -linkedAnchor :: String -> Html -> Html -linkedAnchor frag = anchor ! [href hr_] - where hr_ | null frag = "" - | otherwise = '#': escapeStr frag - documentCharacterEncoding :: Html documentCharacterEncoding = meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"] -- cgit v1.2.3