diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-20 00:25:54 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-20 00:25:54 +0000 |
commit | 5cf769b1cd1d9e76ff5f543aba8b4a15a90b7d88 (patch) | |
tree | c09f786f43f29aba1bdd43587fec0c5162ae441a /src | |
parent | c1ebe94e40a66a092c2cd501eda1edb5ec216938 (diff) | |
download | pandoc-5cf769b1cd1d9e76ff5f543aba8b4a15a90b7d88.tar.gz |
Modified the HTML writer to add invisible anchors to each section
heading. The anchors are derived form the text of the section
heading as described in README. This makes it easy to insert
links that jump from one part of a document to another:
for example, '[back to the Introduction](#Introduction)'.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@246 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index f1bd0f8b5..7ba506acb 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -154,12 +154,14 @@ blockToHtml options (OrderedList lst) = let attribs = if (writerIncremental options) then " class=\"incremental\"" else "" in "<ol" ++ attribs ++ ">\n" ++ (concatMap (listItemToHtml options) lst) ++ "</ol>\n" blockToHtml options HorizontalRule = "<hr />\n" -blockToHtml options (Header level lst) = if ((level > 0) && (level <= 6)) then - "<h" ++ (show level) ++ ">" ++ - (inlineListToHtml options lst) ++ - "</h" ++ (show level) ++ ">\n" - else - "<p>" ++ (inlineListToHtml options lst) ++ "</p>\n" +blockToHtml options (Header level lst) = + let contents = inlineListToHtml options lst in + let simplify = gsub "<[^>]*>" "" . gsub " " "_" in + if ((level > 0) && (level <= 6)) + then "<a id=\"" ++ simplify contents ++ "\"></a>\n" ++ + "<h" ++ (show level) ++ ">" ++ contents ++ + "</h" ++ (show level) ++ ">\n" + else "<p>" ++ contents ++ "</p>\n" listItemToHtml options list = "<li>" ++ (concatMap (blockToHtml options) list) ++ "</li>\n" -- | Convert list of Pandoc inline elements to HTML. |