From 5e039d913f0f8db2e7fc8ea37dee30b174c4594f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 8 Dec 2017 12:16:32 -0800 Subject: Changes for skylighting-0.5. This fixes a bug in 2.0.4, whereby pandoc could not read the theme files generated with `--print-highlight-style`. It also fixes some CSS issues involving line numbers. Highlighted code blocks are now enclosed in a div with class sourceCode. Highlighting CSS no longer sets a generic color for pre and code; we only set these for class `sourceCode`. This will close #4133 and #4128. --- pandoc.cabal | 2 +- src/Text/Pandoc/App.hs | 3 +- src/Text/Pandoc/Writers/Docx.hs | 6 ++-- src/Text/Pandoc/Writers/Ms.hs | 4 +-- stack.pkg.yaml | 2 +- stack.yaml | 3 +- test/lhs-test.html | 64 ++++++++++++++++++++++++----------------- test/lhs-test.html+lhs | 64 ++++++++++++++++++++++++----------------- test/lhs-test.latex | 44 ++++++++++++++-------------- 9 files changed, 106 insertions(+), 86 deletions(-) diff --git a/pandoc.cabal b/pandoc.cabal index 95aef05ac..ac5dffbcf 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -322,7 +322,7 @@ library tagsoup >= 0.14.2 && < 0.15, base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.7, - skylighting >= 0.4.4.1 && < 0.5, + skylighting >= 0.5 && < 0.6, data-default >= 0.4 && < 0.8, temporary >= 1.1 && < 1.3, blaze-html >= 0.5 && < 0.10, diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 7d7d630ea..ae62db4f9 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -1074,7 +1074,8 @@ options = (map T.pack ["text-color" ,"background-color" - ,"line-numbers" + ,"line-number-color" + ,"line-number-background-color" ,"bold" ,"italic" ,"underline" diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index c9eaaf838..d76990284 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -625,12 +625,12 @@ styleToOpenXml sm style = [ mknode "w:u" [] () | tokFeature tokenUnderline toktype ] ] tokStyles = tokenStyles style - tokFeature f toktype = maybe False f $ lookup toktype tokStyles + tokFeature f toktype = maybe False f $ M.lookup toktype tokStyles tokCol toktype = maybe "auto" (drop 1 . fromColor) - $ (tokenColor =<< lookup toktype tokStyles) + $ (tokenColor =<< M.lookup toktype tokStyles) `mplus` defaultColor style tokBg toktype = maybe "auto" (drop 1 . fromColor) - $ (tokenBackground =<< lookup toktype tokStyles) + $ (tokenBackground =<< M.lookup toktype tokStyles) `mplus` backgroundColor style parStyle | hasStyleName "Source Code" (sParaStyleMap sm) = Nothing | otherwise = Just $ diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs index 223d1bcc1..30633cec6 100644 --- a/src/Text/Pandoc/Writers/Ms.hs +++ b/src/Text/Pandoc/Writers/Ms.hs @@ -586,7 +586,7 @@ styleToMs sty = vcat $ colordefs ++ map (toMacro sty) alltoktypes allcolors = catMaybes $ ordNub $ [defaultColor sty, backgroundColor sty, lineNumberColor sty, lineNumberBackgroundColor sty] ++ - concatMap (colorsForToken. snd) (tokenStyles sty) + concatMap (colorsForToken. snd) (Map.toList (tokenStyles sty)) colorsForToken ts = [tokenColor ts, tokenBackground ts] hexColor :: Color -> String @@ -611,7 +611,7 @@ toMacro sty toktype = resetfont = if tokBold || tokItalic then text "\\\\f[C]" else empty - tokSty = lookup toktype (tokenStyles sty) + tokSty = Map.lookup toktype (tokenStyles sty) tokCol = (tokSty >>= tokenColor) `mplus` defaultColor sty -- tokBg = (tokSty >>= tokenBackground) `mplus` backgroundColor sty tokBold = fromMaybe False (tokenBold <$> tokSty) diff --git a/stack.pkg.yaml b/stack.pkg.yaml index aaeb253f4..de878643a 100644 --- a/stack.pkg.yaml +++ b/stack.pkg.yaml @@ -16,7 +16,7 @@ extra-deps: - pandoc-types-1.17.3 - hslua-0.9.3 - hslua-module-text-0.1.2 -- skylighting-0.4.4.1 +- skylighting-0.5 - texmath-0.10 - cmark-gfm-0.1.1 - QuickCheck-2.10.0.1 diff --git a/stack.yaml b/stack.yaml index 48e0f54da..6cd42b23b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,12 +5,11 @@ flags: old-locale: false network-uri: true packages: -- '.' extra-deps: - pandoc-types-1.17.3 - hslua-0.9.3 - hslua-module-text-0.1.2 -- skylighting-0.4.4.1 +- skylighting-0.5 - texmath-0.10 - cmark-gfm-0.1.1 - QuickCheck-2.10.0.1 diff --git a/test/lhs-test.html b/test/lhs-test.html index 95fe40e19..77f75f354 100644 --- a/test/lhs-test.html +++ b/test/lhs-test.html @@ -13,16 +13,24 @@ div.column{display: inline-block; vertical-align: top; width: 50%;}