Closed LiraOnGithub closed 3 days ago
<DetectChar attribute="String" context="string" char="""/>
try context="String"
. It is case-sensitive.
Both the name
of the context
as the value of context
are all lowercase, but if I change all occurences of string to String
it still yields the same result
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE language [ ]>
<language name="Test" version="1" kateversion="5.53" section="Sources" extensions="*.*" mimetype="text/plain" license="LGPL">
<highlighting>
<contexts>
<context attribute="Normal" lineEndContext="#stay" name="normal">
<DetectChar attribute="String" context="String" char="""/>
</context>
<context attribute="String" lineEndContext="#stay" name="String">
<DetectChar attribute="String" context="#pop" char=""" />
</context>
</contexts>
<itemDatas>
<itemData name="Normal" defStyleNum="dsNormal" />
<itemData name="String" defStyleNum="dsString" />
</itemDatas>
</highlighting>
</language>
#!/usr/bin/env cabal
{- cabal:
build-depends: base, text, skylighting, skylighting-core
-}
import Data.Text (pack)
import Skylighting (tokenize, TokenizerConfig(..), defaultSyntaxMap)
import Skylighting.Loader (loadSyntaxFromFile)
main :: IO ()
main = do
Right syntax <- loadSyntaxFromFile "./test.xml"
case tokenize tokenizerConfig syntax $ pack "a\"b\"c" of
Right sourceLines -> print sourceLines
Left e -> putStrLn e
where
tokenizerConfig :: TokenizerConfig
tokenizerConfig = TokenizerConfig
{ traceOutput = False
, syntaxMap = defaultSyntaxMap
}
$ ./test.hs
Unknown syntax or context: ("Test","String")
Also, if that were the case the second and third case would still work, but those fail as well (the ones with haskell.xml and the copy of it)
I think it looks for the context in the wrong place (not the file itself)
tokenizerConfig :: TokenizerConfig
tokenizerConfig = TokenizerConfig
{ traceOutput = False
, syntaxMap = defaultSyntaxMap
}
I think the problem might be this: syntaxMap
is defaultSyntaxMap
, which doesn't include the new syntax you've created.
Yes! That was the issue! Thank you so much :D
When I try to load a syntax file from disk, it seems contexts are not correctly searched for.
Minimal example with unknown language
test.xml
test.hs
When running the minimal application:
Minimal example with copy of haskell.xml
When I try to load a copy of haskell.xml, but change some of the
defStyleNum
s, it partly works:Running this results in the following output:
But I expected the output to be
[[(NormalTok,"a"),(OperatorTok,"`b`"),(NormalTok,"c")]]
. It seems it takes theOperatorTok
from this syntax file, but theOtherTok
from another one.Minimal example with copy of haskell.xml with name "test" in test.xml
When I copy the contents of haskell.xml into test.xml and change the
name
-attribute oflanguage
toTest
, it doesn't work at all: test.xmltest.hs
My assumption is that
<X context="foo" />
tries to find the contextfoo
in a compiled syntax with the name specified in the name of the language-attribute instead of in the same xml-file.