-
Notifications
You must be signed in to change notification settings - Fork 7
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
Code syntax highlighting #4
Comments
Notes on 8/tech/? |
What about it? |
About how 8chan also has code tags for scripts |
I visited 8ch.net and looked at the <pre class="prettyprint prettyprinted" style="display: inline-block;"><code></code></pre> There seems to be no AI included to autodetect a language. So unless a chan explicitly sets the |
@catamphetamine try typing this into the post
and see what happens next, maybe it is pre-generated? |
@DonaldTsang Well, on the screenshot above I can see that it has highlighted C but it doesn't provide the |
Note to self: Seems that the original There seems to be a library called The library supports both loading new language syntaxes on demand (asynchronously) and even loading Prism library core itself (about 20kB gzipped) asynchronously. https://www.npmjs.com/package/react-syntax-highlighter#async-build import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter'; The "async light" version will defer loading all syntaxes and the library itself. A language could be checked for support using |
In that case it shows how lain/arisu is better |
@DonaldTsang deployed on
https://catamphetamine.github.io/captchan/%CE%BB/13961?chan=lainchan
https://arisuchan.jp/λ/res/37.html HTML page response: JSON API response <pre class='block'><code class='block '>#!/usr/bin/ruby↵require
Yeah, those two have been crafted with passion. |
Ahh, I guess I see what's the reason: |
As discussed in the
arisuchan
andlainchan
issue, those two chans have code syntax highlighting.The markup is already generated as a standard one:
A code highlighter could be included on a page.
For example, Prism.
There's an Autoloader plugin that loads syntaxes dynamically.
That would be Prism, but by default it only highlights code (and loads syntaxes) on page load.
React is different — it renders stuff after page load, so there should be a way to re-run Prism highlighter after the code component has rendered.
There seems to be a React wrapper for Prism that does the dynamic re-running thing:
https://github.com/FormidableLabs/prism-react-renderer
The text was updated successfully, but these errors were encountered: