
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A markdown to custom React components library
npm install marksy
import marksy from 'marksy'
// const marksy = require('marksy').marksy
// You can override the default elements with
// React components
const compile = marksy({
h1 ({id, children}) {},
h2 ({id, children}) {},
h3 ({id, children}) {},
h4 ({id, children}) {},
blockquote ({children}) {},
hr () {},
ol ({children}) {},
ul ({children}) {},
p ({children}) {},
table ({children}) {},
thead ({children}) {},
tbody ({children}) {},
tr ({children}) {},
th ({children}) {},
td ({children}) {},
a ({href, title, target, children}) {},
strong ({children}) {},
em ({children}) {},
br () {},
del ({children}) {},
img ({src, alt}) {},
code ({language, code}) {},
codespan ({children}) {}
})
const compiled = compile('# hello', {
// Options passed to "marked" (https://www.npmjs.com/package/marked)
})
compiled.tree // The React tree of components
compiled.toc // The table of contents, based on usage of headers
You can also add your own custom components. You do this by importing marksy/components
. This build of marksy includes babel transpiler which will convert any HTML to React elements and allow for custom components:
import marksy from 'marksy/components'
const compile = marksy({
components: {
MyCustomComponent (props) {
return <h1>{props.children}</h1>
}
}
})
/* MARKDOWN:
# Just a test
<MyCustomComponent>some text</MyCustomComponent>
*/
/* WITH LANGUAGE FOR GENERIC SUPPORT:
# Just a test
'''marksy
<MyCustomComponent>some text</MyCustomComponent>
'''
PS! Use backticks, Github weirdness when parsing example
*/
This will be converted to the component above. You can pass in any kind of props, as if it was normal code.
To enable code highlighting the Prism project needs to be available on window.
npm install
npm start
-> localhost:8080 (development app)FAQs
Convert markdown into react components
The npm package marksy receives a total of 49,706 weekly downloads. As such, marksy popularity was classified as popular.
We found that marksy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.