skylighting 0.4.2 → 0.4.3
raw patch · 4 files changed
+26/−11 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Skylighting.Types: [lineIdPrefix] :: FormatOptions -> Text
- Skylighting.Types: FormatOptions :: Bool -> Int -> Bool -> Bool -> [Text] -> [Text] -> FormatOptions
+ Skylighting.Types: FormatOptions :: Bool -> Int -> Bool -> Bool -> [Text] -> [Text] -> Text -> FormatOptions
Files
- changelog.md +9/−0
- skylighting.cabal +1/−1
- src/Skylighting/Format/HTML.hs +14/−10
- src/Skylighting/Types.hs +2/−0
changelog.md view
@@ -1,5 +1,14 @@ # Revision history for skylighting +## 0.4.3 --- 2017-11-02++ * `FormatOptions`: added `lineIdPrefix` (jgm/pandoc#4031).+ This is needed because a web page may contain several+ code samples, and we need to make sure that the ids on+ lines are unique.+ * HTML formatter: use `lineIdPrefix` in ids for lines.+ * HTML formatter: Don't put href attributes on divs.+ ## 0.4.2 --- 2017-10-26 * HTML output: remove outer div. This prevented margin
skylighting.cabal view
@@ -1,5 +1,5 @@ name: skylighting-version: 0.4.2+version: 0.4.3 synopsis: syntax highlighting library description: Skylighting is a syntax highlighting library with support for over one hundred languages. It derives
src/Skylighting/Format/HTML.hs view
@@ -5,6 +5,7 @@ ) where import Data.List (intersperse)+import Data.Monoid ((<>)) import Data.String (fromString) import qualified Data.Text as Text import Skylighting.Types@@ -79,17 +80,20 @@ -- | Each line of source is wrapped in an (inline-block) div that makes -- subsequent per-line processing (e.g. adding line numnbers) possible. sourceLineToHtml :: FormatOptions -> LineNo -> SourceLine -> Html-sourceLineToHtml opts lno cont = wrapElement ! A.class_ sourceLine- ! A.id lineNum- ! A.href lineRef- ! H.dataAttribute (fromString "line-number") lineNum $- mapM_ (tokenToHtml opts) cont+sourceLineToHtml opts lno cont =+ (if lineAnchors opts+ then H.a ! A.class_ sourceLine+ ! A.id lineNum+ ! A.href lineRef+ ! dataAttrib+ else H.div ! A.class_ sourceLine+ ! A.id lineNum+ ! dataAttrib) $ mapM_ (tokenToHtml opts) cont where sourceLine = toValue "sourceLine"- lineNum = toValue . show . lineNo $ lno- lineRef = toValue . ('#':) . show . lineNo $ lno- wrapElement = if lineAnchors opts- then H.a- else H.div+ lineNum = toValue prefixedLineNo+ lineRef = toValue ('#':prefixedLineNo)+ prefixedLineNo = Text.unpack (lineIdPrefix opts) <> show (lineNo lno)+ dataAttrib = H.dataAttribute (fromString "line-number") lineNum tokenToHtml :: FormatOptions -> Token -> Html tokenToHtml _ (NormalTok, txt) = toHtml txt
src/Skylighting/Types.hs view
@@ -370,6 +370,7 @@ , titleAttributes :: Bool -- ^ Html titles with token types , codeClasses :: [Text] -- ^ Additional classes for Html code tag , containerClasses :: [Text] -- ^ Additional classes for Html container tag+ , lineIdPrefix :: Text -- ^ Prefix for id attributes on lines } deriving (Show, Read, Eq, Ord, Data, Typeable, Generic) instance Binary FormatOptions@@ -383,4 +384,5 @@ , titleAttributes = False , codeClasses = [] , containerClasses = []+ , lineIdPrefix = "" }