Skip to content
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

chore: add fix for docusaurus 3 #9

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

![NPM Build Status](https://github.com/mstroppel/remark-local-plantuml/actions/workflows/npmbuild.yml/badge.svg)

`remark-local-plantuml` is a simple plugin for [remarkjs](https://github.com/remarkjs/remark) that converts PlantUML code locally int inline html image nodes.
`remark-local-plantuml` is a simple plugin for [remarkjs](https://github.com/remarkjs/remark) that converts PlantUML code locally to inline html SVG nodes.

## Installing

Expand Down Expand Up @@ -43,9 +43,9 @@ console.log(output);

## Integration

You can use this plugin in any frameworks support remarkjs.
You can use this plugin in any frameworks that support remarkjs.

If you want to use in the classic preset of [Docusaurus 2](https://v2.docusaurus.io/), like me, set configuration in your `docusaurus.config.js` like following.
If you want to use in the classic preset of [Docusaurus 2 or 3](https://docusaurus.io/), set configuration in your `Docusaurus.config.js` like following:

```javascript
const simplePlantUML = require("@mstroppel/remark-local-plantuml");
Expand All @@ -67,6 +67,57 @@ presets: [
//...
```

## Issues

### Issues Using Docusaurus 3

when on `npm run start` or `npm run build` of Docusaurus the following error appears:

```
Error: MDX compilation failed for file "C:\data\source\tapio.InternalDocs\docs\context.md"
Cause: Cannot handle unknown node `raw`
Details:
Error: Cannot handle unknown node `raw`
```

Use the [rehype-raw](https://www.npmjs.com/package/rehype-raw) as `rehypeplugin` in Docusaurus.

Install `rehype-raw`:

```bash
npm install rehype-raw
```

Add the following to the top of `docusaurus.config.js` file:
and add the [MDX plugin](https://docusaurus.io/docs/markdown-features/plugins#installing-plugins) in next to the `remark-local-plantuml` plugin:

```javascript
const localPlantUML = require("@mstroppel/remark-local-plantuml");
import rehypeRaw from 'rehype-raw';
const rehypeRawOptions = {
passThrough: ['mdxjsEsm']
};

// your configurations...

presets: [
[
"@Docusaurus/preset-classic",
{
docs: {
sidebarPath: require.resolve("./sidebars.js"),
remarkPlugins: [localPlantUML],
rehypePlugins: [[rehypeRaw, rehypeRawOptions]],
}
}
]
],

//...
```

See also the [example docusaurus project](https://github.com/mstroppel/remark-local-plantuml-docusaurus).

## Many Thanks To

- [remark-simple-plantuml](https://github.com/akebifiky/remark-simple-plantuml)
Expand Down