Skip to content

Commit 097baea

Browse files
committed
Update README
1 parent a82ddb6 commit 097baea

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
PlainBelt
2-
=========
1+
[![Test](https://github.com/plainbelt/plainbelt/actions/workflows/test.yml/badge.svg)](https://github.com/plainbelt/plainbelt/actions/workflows/test.yml)
32

4-
> A toolbelt for all your plain text
3+
# PlainBelt
54

5+
> A toolbelt for your plain text
66
77
## Development setup
88

@@ -11,4 +11,10 @@ yarn
1111
yarn start
1212
```
1313

14-
Enjoy!
14+
## Build binary
15+
16+
```
17+
yarn package
18+
```
19+
20+
Checkout the `release` folder and enjoy!

src/components/md-to-html/MarkdownToHtml.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
1+
/* eslint-disable react/no-danger */
12
import React, { useState } from 'react';
23
import marked from 'marked';
34

45
const Md2Html = () => {
56
const [md, setMd] = useState('# Hello\n> This is a quote');
7+
const [preview, setPreview] = useState(false);
68

79
const handleChange = (evt: { target: { value: string } }) =>
810
setMd(evt.target.value);
911

1012
return (
11-
<div className="flex min-h-full">
12-
<textarea
13-
onChange={handleChange}
14-
className="flex-1 min-h-full bg-white p-4"
15-
value={md}
16-
/>
17-
<div className="mx-1" />
18-
<textarea
19-
className="flex-1 min-h-full bg-blue-100 p-4"
20-
value={marked(md)}
21-
disabled
22-
/>
13+
<div className="min-h-full flex flex-col">
14+
<div className="flex justify-end mb-1">
15+
<button
16+
type="button"
17+
className="rounded bg-gray-300 px-2 py-1 outline-none text-sm text-gray-600"
18+
onClick={() => setPreview(!preview)}
19+
>
20+
{preview ? 'Raw HTML' : 'Preview'}
21+
</button>
22+
</div>
23+
<div className="flex min-h-full flex-1">
24+
<textarea
25+
onChange={handleChange}
26+
className="flex-1 min-h-full bg-white p-4"
27+
value={md}
28+
/>
29+
<div className="mx-1" />
30+
{preview ? (
31+
<section
32+
className="flex-1 min-h-full bg-blue-50 p-4 prose"
33+
dangerouslySetInnerHTML={{ __html: marked(md) }}
34+
/>
35+
) : (
36+
<textarea
37+
className="flex-1 min-h-full bg-blue-100 p-4"
38+
value={marked(md)}
39+
disabled
40+
/>
41+
)}
42+
</div>
2343
</div>
2444
);
2545
};

0 commit comments

Comments
 (0)