skylighting-core 0.10.5 → 0.10.5.1
raw patch · 7 files changed
+104/−6 lines, 7 filesdep ~containersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: containers
API changes (from Hackage documentation)
Files
- changelog.md +10/−0
- skylighting-core.cabal +4/−2
- src/Regex/KDE/Match.hs +5/−1
- src/Skylighting/Tokenizer.hs +2/−3
- test/cases/docbook.xml +13/−0
- test/expected/docbook.xml.native +69/−0
- test/test-skylighting.hs +1/−0
changelog.md view
@@ -1,5 +1,15 @@ # Revision history for skylighting and skylighting-core +## 0.10.5.1++ * Regex: Allow lookaheads to capture groups. Previously+ captures in lookaheads, like `(?=(a*))`, were ignored. This+ led to errors highlighting xml and probably other formats (#121).++ * Throw an exception if a capture group isn't defined (with 'dynamic')+ rather than simply having getCapture fail so that the rule fails.+ This will make it easier to debug issues like #121.+ ## 0.10.5 * Fix regression from 0.10.3 with Haskell highlighting of Char (#120).
skylighting-core.cabal view
@@ -1,5 +1,5 @@ name: skylighting-core-version: 0.10.5+version: 0.10.5.1 synopsis: syntax highlighting library description: Skylighting is a syntax highlighting library. It derives its tokenizers from XML syntax@@ -59,6 +59,7 @@ test/cases/life.lua test/cases/hk91.html test/cases/if.cmake+ test/cases/docbook.xml test/cases/issue41.djangotemplate test/expected/abc.ada.native test/expected/abc.agda.native@@ -91,6 +92,7 @@ test/expected/hk91.html.native test/expected/if.cmake.native test/expected/issue41.djangotemplate.native+ test/expected/docbook.xml.native cabal-version: >=1.10 @@ -130,7 +132,7 @@ safe, base64-bytestring, blaze-html >= 0.5,- containers >= 0.5.8.2,+ containers >= 0.6.0.1, ansi-terminal >= 0.7, colour >= 2.0 hs-source-dirs: src
src/Regex/KDE/Match.hs view
@@ -65,7 +65,11 @@ exec _ _ AssertEnd = Set.filter (\m -> matchOffset m == B.length (matchBytes m)) exec _ _ AssertBeginning = Set.filter (\m -> matchOffset m == 0) exec top _ (AssertPositive dir regex) =- Set.filter (\m -> not (null (exec top dir regex (Set.singleton m))))+ Set.unions . Set.map+ (\m -> Set.map (\m' -> -- we keep captures but not matches+ m'{ matchBytes = matchBytes m,+ matchOffset = matchOffset m })+ $ exec top dir regex (Set.singleton m)) exec top _ (AssertNegative dir regex) = Set.filter (\m -> null (exec top dir regex (Set.singleton m))) exec _ _ AssertWordBoundary = Set.filter atWordBoundary
src/Skylighting/Tokenizer.hs view
@@ -36,7 +36,6 @@ import Data.Semigroup #endif - newtype ContextStack = ContextStack{ unContextStack :: NonEmpty Context } deriving (Show) @@ -527,7 +526,7 @@ Just (matchedBytes, capts) -> do unless (null capts) $ modify $ \st -> st{ captures =- IntMap.map (toSlice matchedBytes) capts }+ IntMap.map (toSlice inp) capts } takeChars (UTF8.length matchedBytes) _ -> mzero @@ -575,7 +574,7 @@ getCapture capnum = do capts <- gets captures case IntMap.lookup capnum capts of- Nothing -> mzero+ Nothing -> throwError $ "Capture " <> show capnum <> " not defined!" Just x -> decodeBS x keyword :: KeywordAttr -> WordSet Text -> ByteString -> TokenizerM Text
+ test/cases/docbook.xml view
@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">+<article>+ <!-- just an example -->+ <sect1>+ <title>The Month of May</title>+ <para>+ When you install DocBook Tools a number of files are added to+ <filename class="directory">/usr/bin</filename>, including+ <filename>db2html</filename>, and <filename>db2pdf</filename>.+ </para>+ </sect1>+</article>
+ test/expected/docbook.xml.native view
@@ -0,0 +1,69 @@+[ [ ( FunctionTok , "<?xml" )+ , ( OtherTok , " version=" )+ , ( StringTok , "\"1.0\"" )+ , ( OtherTok , " encoding=" )+ , ( StringTok , "\"utf-8\"" )+ , ( FunctionTok , "?>" )+ ]+, [ ( DataTypeTok , "<!DOCTYPE" )+ , ( NormalTok , " " )+ , ( DataTypeTok , "article" )+ , ( NormalTok , " PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\"" )+ , ( DataTypeTok , ">" )+ ]+, [ ( NormalTok , "<" )+ , ( KeywordTok , "article" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok , " " )+ , ( CommentTok , "<!-- just an example -->" )+ ]+, [ ( NormalTok , " <" )+ , ( KeywordTok , "sect1" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok , " <" )+ , ( KeywordTok , "title" )+ , ( NormalTok , ">The Month of May</" )+ , ( KeywordTok , "title" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok , " <" )+ , ( KeywordTok , "para" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok+ , " When you install DocBook Tools a number of files are added to"+ )+ ]+, [ ( NormalTok , " <" )+ , ( KeywordTok , "filename" )+ , ( OtherTok , " class=" )+ , ( StringTok , "\"directory\"" )+ , ( NormalTok , ">/usr/bin</" )+ , ( KeywordTok , "filename" )+ , ( NormalTok , ">, including" )+ ]+, [ ( NormalTok , " <" )+ , ( KeywordTok , "filename" )+ , ( NormalTok , ">db2html</" )+ , ( KeywordTok , "filename" )+ , ( NormalTok , ">, and <" )+ , ( KeywordTok , "filename" )+ , ( NormalTok , ">db2pdf</" )+ , ( KeywordTok , "filename" )+ , ( NormalTok , ">." )+ ]+, [ ( NormalTok , " </" )+ , ( KeywordTok , "para" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok , " </" )+ , ( KeywordTok , "sect1" )+ , ( NormalTok , ">" )+ ]+, [ ( NormalTok , "</" )+ , ( KeywordTok , "article" )+ , ( NormalTok , ">" )+ ]+]
test/test-skylighting.hs view
@@ -317,6 +317,7 @@ , ("(?|(abc)|(def))", "abc", Just ("abc", [(1,"abc")])) , ("(?|(abc)|(def))", "def", Just ("def", [(1,"def")])) , ("(?:(abc)|(def))", "def", Just ("def", [(2,"def")]))+ , ("d(?=(bc)|(ef))", "def", Just ("d", [(2,"ef")])) ]