Skip to content

Commit

Permalink
Added reference docs related to markdown parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
salmenus committed Jun 19, 2024
1 parent 6878631 commit dc4c212
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions docs/docs/reference/002-ui/005-markdown.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
sidebar_label: 'Markdown'
---

# Markdown Parsing

`NLUX` comes with its own markdown parser that can be used to render markdown content in the chat area.<br />
On top of that, a `<Markdown>` primitive is provided to render markdown in custom renderers.

---

## Usage

---

### With Streaming Custom Renderers
<br />
<br />

In order to use markdown stream parser with custom renderers, you can simply pass the `props.containerRef`
to the container element where you would like to add the rendered markdown content, and `NLUX` will
take care of the rest.

```jsx
import {memo} from 'react';
import {ResponseRenderer, Markdown} from '@nlux/react';

const responseRenderer: ResponseRenderer<string> = memo((props) => {
const {props.containerRef} = props;

return (
<div className="myCustomRenderer">
<div ref={props.containerRef}/>
</div>
);
});
```

---

### With Batched Custom Renderers
<br />
<br />

If you are using batched custom renderers, or your would like to add markdown to initial conversation messages,
you can use the `<Markdown>` primitive.

```jsx
import {memo} from 'react';
import {ResponseRenderer, Markdown} from '@nlux/react';

const responseRenderer: ResponseRenderer<string> = memo((props) => {
const {content} = props;
return (
<div className="myCustomRenderer">
<Markdown>{content}</Markdown>
</div>
);
});
```
File renamed without changes.
File renamed without changes.

0 comments on commit dc4c212

Please sign in to comment.