-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax highlighting support for typescript #57
Comments
(there's also a typescript-react file which could be useful although i don't need it myself right now) |
emmanueltouzery <notifications@github.com> writes:
so, KDE has a syntax highlight file for typescript:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/typescript.xml
But skylighting doesn't include it. I think typescript is popular enough to warrant it, but if it's not, I'm interested how could I still fulfill my use-case...
I'd be happy to add it.
My use-case is a hakyll blog in which I would add typescript samples. Now.. I see that pandoc has the `--syntax-definition` command-line option, so I could use the XML file directly by hand, and as far as I can tell this is reachable through the pandoc API through `optSyntaxDefinitions`. However I think that hakyll calls pandoc another way. I see a call `pandocCompilerWith defaultHakyllReaderOptions defaultHakyllWriterOptions` which I could customize but I don't see where I could plug `optSyntaxDefinitions` there. Also I'm not sure the extra syntax definitions would only active for typescript blocks..
You need to ask hakyll people about that.
I tried to clone `skylighting` and add typescript.xml and add `Skylighting.Syntax.Typescript` in the skylighting cabal file and put my modified skylighting-core as a dependency, but the pandoc I got still didn't know about typescript.
Then I added also my modified skylighting as a dependency, but it fails to build:
Preprocessing library for skylighting-0.7.4..
Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4: can't find source for
Skylighting/Syntax in src,
I think the issue is that stack doesn't know to do a
"bootstrap build." To solve this, after you've built
your modified skylighting-core, do a cabal sdist to
create a distribution tarball, and give stack the path
to that...
|
thank you for the feedback! I've now tried to run
Indeed I see this in typescript.xml from KDE =>
I have no idea what this means :-( I'll contact the hakyll developers regarding exposing this syntax-definition option for hakyll users. I was under the impression that hakyll offers like two APIs and one one exported the syntax-definition option. All the |
I'm adding typescript now. The error is because the
javascript definition also needs updating.
emmanueltouzery <notifications@github.com> writes:
… thank you for the feedback! I've now tried to run `stack test` in skylighting-core after adding `typescript.xml` and I noticed this test failure:
TypeScript: FAIL
test/test-skylighting.hs:188:
Unexpected error: IncludeRules in TypeScript requires undefined context FindStrings##JavaScript
input = "let characters = \"BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM\";\nlet blocks = characters.split(\" \").map(pair => pair.split(\"\"));\n \nfunction isWordPossible(word) {\n var letters = [...word.toUpperCase()];\n var length = letter"
Indeed I see this in typescript.xml from KDE =>
<context name="FindStrings" attribute="Normal Text" lineEndContext="#stay">
<DetectChar context="Template" attribute="Template" char="`" />
<IncludeRules context="FindStrings##JavaScript" />
</context>
I have no idea what this means :-(
I'll contact the hakyll developers regarding exposing this syntax-definition option for hakyll users. I was under the impression that hakyll offers like two APIs and one one exported the syntax-definition option. All the `Ext_` options for instance are reachable from hakyll already. Anyway, I'll open a bug there too, but I'm still interested in getting typescript in pandoc if it's not too hard.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#57 (comment)
|
I'm using this feature now, and it seems to be out of date (maybe it's the KDE definitions that are old)? Here's how the syntax highlighting looks in GitHub: // sample1.ts
export interface StringValidator {
isAcceptable(s: string): boolean;
} // sample2.ts
import { StringValidator } from 'sample1' Here's how it looks in LaTeX/PDF: It seems like I am trying to link to this description from the bug (issue) at KDE.org. |
Looking more at this, I see that the typescript.xml is supposed to (in KDE) extend the keywords from javascript.xml:
Is it possible that the include isn't working via skylighter? |
That's it! We never did support the include element in list contexts. |
As a workaround you can just copy the list into typescript.xml and use it with |
Looks like typescript.xml uses include extensively. |
I'm attaching the result in case someone wants to use it (maybe you must rename it to a |
so, KDE has a syntax highlight file for typescript:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/typescript.xml
But skylighting doesn't include it. I think typescript is popular enough to warrant it, but if it's not, I'm interested how could I still fulfill my use-case...
My use-case is a hakyll blog in which I would add typescript samples. Now.. I see that pandoc has the
--syntax-definition
command-line option, so I could use the XML file directly by hand, and as far as I can tell this is reachable through the pandoc API throughoptSyntaxDefinitions
. However I think that hakyll calls pandoc another way. I see a callpandocCompilerWith defaultHakyllReaderOptions defaultHakyllWriterOptions
which I could customize but I don't see where I could plugoptSyntaxDefinitions
there. Also I'm not sure the extra syntax definitions would only active for typescript blocks..I tried to clone
skylighting
and add typescript.xml and addSkylighting.Syntax.Typescript
in the skylighting cabal file and put my modified skylighting-core as a dependency, but the pandoc I got still didn't know about typescript.Then I added also my modified skylighting as a dependency, but it fails to build:
So I'm stuck right now :-(
The text was updated successfully, but these errors were encountered: