diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-11-02 16:38:06 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-11-02 16:38:06 -0700 |
commit | 5dfe131ee07065dc7b68912d9a068508e29e18a4 (patch) | |
tree | 54cefde18f1dfe9e7232847624981bd54f9099c0 | |
parent | 856587ff63b1e89c71b73a367f5ba1730050e6dd (diff) | |
download | pandoc-5dfe131ee07065dc7b68912d9a068508e29e18a4.tar.gz |
Support `lineAnchors` (or `line-anchors`) in code blocks, for HTML.
-rw-r--r-- | MANUAL.txt | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Highlighting.hs | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index 7a533fe15..9122ec8e0 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -2008,6 +2008,12 @@ block above will appear as follows: </code> </pre> +The `numberLines` (or `number-lines`) class will cause the lines +of the code block to be numbered, starting with `1` or the value +of the `startFrom` attribute. The `lineAnchors` (or +`line-anchors`) class will cause the lines to be clickable +anchors in HTML output. + A shortcut form can also be used for specifying the language of the code block: diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs index cd8c5fd4b..9c90b229e 100644 --- a/src/Text/Pandoc/Highlighting.hs +++ b/src/Text/Pandoc/Highlighting.hs @@ -85,6 +85,8 @@ highlight syntaxmap formatter (ident, classes, keyvals) rawCode = let firstNum = fromMaybe 1 (safeRead (fromMaybe "1" $ lookup "startFrom" keyvals)) fmtOpts = defaultFormatOpts{ startNumber = firstNum, + lineAnchors = any (`elem` + ["line-anchors", "lineAnchors"]) classes, numberLines = any (`elem` ["number","numberLines", "number-lines"]) classes, lineIdPrefix = if null ident |