docs: a code component for react, svelte, vue and angular - #85
Open
lvolland wants to merge 2 commits into
Open
Conversation
Member
…d-highlight#42 follows the layout the repo already uses for node-require and node-ts-module, which is what speed-highlight#42 did and this pr did not. takes the theme import from speed-highlight#42 so the component carries its own styling, with the path that resolves: dist/themes is not exported, themes/ is. Co-authored-by: Duncan Lock <dlock@photonic.com>
Contributor
Author
|
hadn't seen #42 — @dflock got to vue first and was right on two things i got wrong: one folder per framework (matching one change to their version: rebuilt with no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
a
Codecomponent per framework, one folder each, ticking the four boxes on #26.this supersedes #42, and takes two things from it
i hadn't seen #42 when i opened this. @dflock got to vue first, seventeen months ago,
and was right on two counts where i was wrong:
node-require/andnode-ts-module/. i hadfour loose files in
examples/frameworks/. restructuredinstead of relying on a
<link>the reader has to remember. adopted in all fourtheir
App.vueis here too, and the commit credits them.the one thing i changed from #42 is the path.
@speed-highlight/core/dist/themes/default.cssis not reachable —
dist/themeswas never inexports:closes #42, and #26.
verified
all four are the exact files that produced that screenshot, in one vite 8 production
build, with no
<link>in the page — the styling comes from the components alone:for angular i also checked the built dom keeps
class="shj-lang-js shj-multiline"and thegutter cells, since that was the one thing i wasn't sure survived its sanitizer.
two things the components have in common, and why
they render the string, they don't highlight the node.
highlightElementon a mountednode fights the framework: it owns that dom and wipes the spans on its next render.
they all guard the same race.
highlightTextis async because it imports the language,so a component whose props change before that resolves would paint the stale result over the
new one. i built #42's component against vue 3.5.40 and changed its props after mount to be
sure this was worth the lines:
notes
sanitizeescapes&,<and>in every token. i threw 7 injection payloads across 5 languages athighlightTextandno foreign tag came out. each readme says so, because it is the first question anyone asks
bypassSecurityTrustHtml— its sanitizer keeps theclassattribute. ichecked the allow-list and then checked the rendered dom
package.jsonper framework — one component each, meantto be copied
[BUG] Unable to import language when bundled by Vite. #31 is out of date, worth knowing