-
Hi everybody, first of all many thanks for the great implementation of highlightjs in Angular. Works like a charm and especially the StackBlitz examples really help to get started! Is there a proper way to add my language description, which is currently not yet integrated into the main HighlightsJS repo, into the installed ngx-zighlightjs version in my angular project? Would be happy if someone of you has a hint :-) I'm not the best TS/JS programmer myself. Normally active on the backend side of life, but this project is definitely fun! If there is no elegant solution I intend to just fork highlightjs, add my language and then build the package locally but this feels somewhat underwhelming. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @josor001, you should be able to get it to work, try to reproduce what you've tried in a stackblitz https://stackblitz.com/edit/ngx-highlightjs?file=src%2Fapp%2Fapp.module.ts, don't forget to add your language file in the stackblitz and I can look into it |
Beta Was this translation helpful? Give feedback.
-
Hi guys, so I finally found the drive to give my issue another try. After tinkering for a couple of hours I was able to find the solution which is painfully easy (as almost always for programming issues :D). So basically the issue was twofold. In order to use the
To fix the line number problem you can do the same, create a folder
This external declaration is of course only a crutch and it would be nicer if the declaration was done directly in the NPM modules themselves. Compiling new highlightjs grammars just unfortunately doesn't work if the folder itself contains a module declaration. Maybe there is a better solution for this on the compilation process of highlightjs. After that I could load the imported language but the syntax highlighting via the directive still didn't work, after some investigation I found out that there was a small bug in the grammar as I had marked some characters as illegal that weren't, i.e., my code snippets that I wanted to highlight always contained illegal characters which caused the highlighter to do nothing. I released a new version of my grammar that fixed the illegal characters and now everything works like a charm 👍 |
Beta Was this translation helpful? Give feedback.
Hi guys,
so I finally found the drive to give my issue another try. After tinkering for a couple of hours I was able to find the solution which is painfully easy (as almost always for programming issues :D).
So basically the issue was twofold.
In order to use the
import('hljs-lemma/src/languages/lemma')
statement to import my language definition, I needed to provide a typescript module definition. I believe we currently have the same issue for thelineNumbersLoader: () => import('highlightjs-line-numbers.js'),
statement in every stackblitz #234 .To fix this, it is necessary to either provide a d.ts file that declares the module inside the npm package or, if you do not have control over t…