Comments (4)
Wow @wooorm ! That's an impressive work!
One thine that concerns me is the usage on browser: https://github.com/wooorm/refractor#browser
I do not suggest using the pre-built files or requiring refractor in the browser as that would include a 250kb (90kb GZipped) file.
Instead, require refractor/core.js, and include only the used highlighters. For example:
Not sure how I should adapt this along with the current PrismCode
API.
from react-prism.
Maybe I should provide them two components, one is the original PrismCode
component.
The other one would be PrismRefactor
component, and the client would have to use it like this:
var refractor = require('refractor/core.js');
var jsx = require('refractor/lang/jsx.js');
refractor.register(jsx);
render(<PrismRefactor>{'JSX CODE'}</PrismRefactor>);
from react-prism.
Even better:
var { PrismRefactor} = require('react-prism');
require('react-prism/register/refractor/lang/jsx'); // Which will call refractor.register(jsx); in that file
render(<PrismRefactor>{'JSX CODE'}</PrismRefactor>);
from react-prism.
Thank you!
react-syntax-highlighter
comes with a βlightβ build, similar to what you suggested, and I think that that is the best solution:
Normal build
Including all languages.
import {PrismCode} from "react-prism";
// ...
Light build
Includes only core languages.
import {PrismCode, register} from 'react-prism/light';
import js from 'react-prism/lang/javascript';
register(js);
// ...
You could also do the auto-register thing, but then languages need to require the light build themselves, and they wonβt export anything, which I personally think is a bit weird, but π€·ββοΈ
from react-prism.
Related Issues (14)
- Prism.js loaded every time the component renders HOT 5
- Support for React 0.13 HOT 2
- Project summary has a typo: hightlight HOT 3
- Use PureComponent instead of react-addons-pure-render-mixin HOT 5
- custom highlighting style HOT 3
- [Question] How to add jsx event? HOT 1
- Plans to support editing? HOT 3
- global prism
- Example too complicated to follow HOT 1
- Error: Prism is not defined HOT 3
- Adding prism on dangerouslySetInnerHTML HOT 1
- How do I access the `data-line` attribute?
- language-regex doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-prism.