-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Export hljs object #169
Export hljs object #169
Conversation
Ability to register languages is missing without it. Workaround is to import the dependency manually, but urgh..
Hi. Thanks for your contribution. I'm not sure if import and customize hljs from the _config file is a good idea. What do you thing about adding this option to the plugin? Something like this: site.use(codeHighlight({
languages: { javascript, css, html }
})); Internally, the plugin could do this: for (const [name, lang] of Object.entries(options.languages)) {
hljs.registerLanguage(name, lang);
} Doing so, the plugin doesn't need to export anything to be configured. This is how all other plugins work. |
That definetely works :) |
Nice! Do you like to implement it in this pull request? I'll be happy to merge 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.
Added languages property on highlightjs plugin options to register languages.
plugins/code_highlight.ts
Outdated
@@ -1,6 +1,8 @@ | |||
import hljs, { HighlightOptions } from "../deps/highlight.ts"; | |||
import { merge } from "../core/utils.ts"; | |||
|
|||
export { hljs }; |
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.
do not export, rather expose a languages property.
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.
It did not push changes from github editor...
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.
Added languages property on highlightjs plugin options to register languages.
plugins/code_highlight.ts
Outdated
@@ -1,6 +1,8 @@ | |||
import hljs, { HighlightOptions } from "../deps/highlight.ts"; | |||
import { merge } from "../core/utils.ts"; | |||
|
|||
export { hljs }; |
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.
It did not push changes from github editor...
Had a bit of troubles with the github.dev editor, it's probably smart to squash the commits for better commit message :D |
There are some problems regarding to the typescript types. I think it's better to make changes in local and test it before commit. |
Yeah, I am currently not on my PC with an editor, so I am using github.dev :) |
Ok, nice! |
Should be good to go |
Seems like the esm mirror doesn't export types :( I'll look through highlight.js source code and find the type manually. |
Please re-run :) |
Co-authored-by: Oscar Otero <oom@oscarotero.com>
plugins/code_highlight.ts
Outdated
@@ -30,6 +33,13 @@ export default function (userOptions?: Partial<Options>) { | |||
// @ts-ignore: Property 'configure' does not exist on type '{}' | |||
hljs.configure(options.options); | |||
|
|||
if (options.languages) { | |||
for (const [name, fn] of Object.entries(userOptions.languages)) { |
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.
missed change it here
thanks! |
Ability to register languages is missing without it. Workaround is to import the dependency manually, but urgh..