
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
tsx-to-html
Advanced tools
A simple jsx runtime to transform your tsx into html strings.
className
hacks// tsconfig.json
{
"jsx": "react-jsx",
"jsxImportSource": "tsx-to-html"
}
import { toHtml } from "tsx-to-html"
toHtml(<div class="foo"></div>) // '<div class="foo"></div>'
You can influence how jsx elements (hast elements) are being transformed into strings
by pushing a properties transformer (Properties -> Properties
) into the
propertiesTransformers
array.
In fact that's what this library is doing to transform class and style objects to strings:
import * as TSX from "tsx-to-html";
TSX.propertiesTransformers.push((properties) => {
if ("class" in properties && isObject(properties["class"])) {
properties["class"] = Object.entries(properties["class"])
.filter(([, enabled]) => enabled)
.map(([key]) => key)
.join(" ");
}
return properties;
});
You can use a Record<string, boolean>
to define which classes will be included
in the output
toHtml(<div class={{foo: true, bar: false}}></div>) // '<div class="foo"></div>'
Inline styles can be given via a CSSStyleDeclaration
object, similar to react.
toHtml(<div style={{display: "flex", flexDirection: "column"}}></div>) // '<div style="display:flex;flex-direction:column"></div>'`
Every other lib I've seen writes a lot of pre-existing logic themselves. Why not just re-use libraries like hastscript who have millions of downloads per week and will probably do their job better and faster?
FAQs
A simple jsx runtime to transform your tsx into html strings.
The npm package tsx-to-html receives a total of 1 weekly downloads. As such, tsx-to-html popularity was classified as not popular.
We found that tsx-to-html demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.