-
Notifications
You must be signed in to change notification settings - Fork 6
Make usable from typescript file using npm imports #13
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LanguageFn } from "highlight.js"; | ||
|
||
declare module 'highlight.js-tsql' { | ||
const tsql: LanguageFn; | ||
export default tsql; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,15 @@ Simply load this module after loading Highlight.js. You'll use the minified vers | |
|
||
For more details of the usage see [Highlight.js main page](https://github.com/highlightjs/highlight.js#highlightjs). | ||
|
||
### Usage with TypeScript import from npm package | ||
|
||
```typescript | ||
import hljs from 'highlight.js'; | ||
|
||
import tsql from 'highlight.js-tsql'; | ||
hljs.registerLanguage('tsql', tsql); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't work as it is in terms of importing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the example to include the css import. Did a local pack and installed the package locally and the styles resolved successfully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, thanks a lot! LGTM - @joshgoebel, anything from you? |
||
``` | ||
|
||
## Authors | ||
|
||
[David Simner](https://github.com/DavidSimner), [Greg Smulko](https://github.com/Greg-Smulko) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
{ | ||
"name": "highlight.js-tsql", | ||
"description": "Syntax highlighting for T-SQL.", | ||
"main": "dist/tsql.js", | ||
"main": "src/languages/tsql.js", | ||
"types": ".types/tsql.d.ts", | ||
"keywords": [ | ||
"highlight", | ||
"syntax", | ||
"T-SQL", | ||
"sql" | ||
], | ||
"homepage": "https://github.com/highlightjs/highlightjs-tsql", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "Greg Smulko", | ||
"bugs": { | ||
"url": "https://github.com/highlightjs/highlightjs-tsql/issues" | ||
|
@@ -23,5 +24,8 @@ | |
"dist/tsql.min.js", | ||
"dist/tsql.es.min.js", | ||
"dist/ssms.min.css" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Probably the same about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd think so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
] | ||
], | ||
"devDependencies": { | ||
"highlight.js": "^11.6.0" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a production dependency, not a dev one, isn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest a looser There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to a dependency instead of dev dependency and set to @joshgoebel would you prefer I specifically make it |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth following the convention from https://github.com/highlightjs/highlight.js/tree/main/types , so
types
rather than.types
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed that.