Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

enable syntax highlighting for source plugin #384

Closed

Conversation

ChristopherBiscardi
Copy link

Related Issue #300

screen shot 2016-07-19 at 9 27 05 am

This PR makes changes to the webpack config of the dev example. I have a pending PR that adds CSS Modules support to highlight.js at highlightjs/highlight.js#1234. This would remove the need to modify the webpack config for the example project. For now, the styles are global 馃槥

I'm asking for review on the approach here, since it introduces global styles currently and the css-modules approach isn't merged into highlight.js

@nikgraf
Copy link
Member

nikgraf commented Jul 20, 2016

@ChristopherBiscardi it still works fine if you don't apply the global styling, correct? In that case I think this approach is still fine.

In case your PR for highlight won't get merged it might be interesting if there is a lib like highlight using inline-styles.

@nikgraf
Copy link
Member

nikgraf commented Jul 20, 2016

The PR needs a small cleanup to comply with the linting. For the import linting to work highlight.js should be added to the package.json in the root directory as devDepedency.

@ChristopherBiscardi
Copy link
Author

it still works fine if you don't apply the global styling, correct?

If the dev webpack config was not adjusted to exclude highlight css from CSS Modules processing: The source code is still processed just fine and the CSS is included in it's mangled form (which means everything will work, but the classnames won't match up with the generated source). The CSS Modules mangled classnames can not be applied until either that PR is merged or I move to publish a fork under ~"hljs-modules".

In case your PR for highlight won't get merged it might be interesting if there is a lib like highlight using inline-styles.

Take a look at how I do it with the highlight.js branch here. It's a bit convoluted (read: require hook) for reasons that are only relevant to my blog setup, but ideally you would be able to call hljs.configure({ classNames: css }); and highlight would use whatever compiled classnames you want.

Does that fulfill your "inline-styles" idea? I'm considering maintaining the PR as a fork on a longer term basis if the PR is not merged, since this feature is extremely useful for me.

@ChristopherBiscardi
Copy link
Author

Given the discussion on this similar-in-intent PR which I just saw, and the lack of response on my own PR (~20 days, which fits with previous discussion), I intend to release the fork as hljs-modules.

@nikgraf Would using said package be an acceptable path for carte-blanche?

@FezVrasta
Copy link
Contributor

FezVrasta commented Jul 31, 2016

Have you considered to use react-highlight (or any other alternative)? https://github.com/akiran/react-highlight

It seems to have a smaller footprint on the project.

@wmertens
Copy link
Collaborator

wmertens commented Jan 9, 2017

You could also use https://github.com/styled-components/styled-components/blob/master/docs/api.md#injectglobal to inject the css directly? Then it is not dependent on the webpack config.

@FezVrasta react-highlight just uses highlight.js, so not sure how that can be lighter-weight?

@FezVrasta
Copy link
Contributor

Because you don't have to manually integrate the library in React.

@ChristopherBiscardi
Copy link
Author

closing for inactivity to clean up my PRs :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants