jsx-md
Version:
Generate markdown files with a React-like syntax.
43 lines (33 loc) • 1.69 kB
Markdown
# jsx-md
[](https://npmjs.org/package/jsx-md)
[](https://npmjs.org/package/jsx-md)
[](https://github.com/dbartholomae/jsx-md/issues)
[](https://github.com/dbartholomae/jsx-md/actions?query=workflow%3A"Build+and+deploy")
[](https://codecov.io/gh/dbartholomae/jsx-md)
[](https://david-dm.org/dbartholomae/jsx-md)
[](https://david-dm.org/dbartholomae/jsx-md?type=dev)
Generate markdown files with a React\-like syntax.
## Usage
```tsx
// We need to tell the JSX transpiler that in this file,
// instead of React we use the custom createElement and Fragment
// functions from jsx-md
/* @jsx MD */
/* @jsxFrag Fragment */
import MD, { Component, Fragment, Heading, LineBreak, render, Text } from "jsx-md";
import { writeFileSync } from "fs";
import pkg from "./package.json";
const Readme: Component = () => (
<>
<Heading level={1}>{pkg.name}</Heading>
<Text>{pkg.description}</Text>
<LineBreak />
</>
);
async function writeReadme() {
writeFileSync("README.md", await render(<Readme />));
}
void writeReadme();
```
## Documentation
There's a [documentation](https://dbartholomae.github.io/jsx-md) of all elements you can use.