Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micheleriva/editorjs-go
Fast markdown/HTML generator for Editor.js
https://github.com/micheleriva/editorjs-go
Last synced: 3 months ago
JSON representation
Fast markdown/HTML generator for Editor.js
- Host: GitHub
- URL: https://github.com/micheleriva/editorjs-go
- Owner: micheleriva
- License: agpl-3.0
- Created: 2020-09-02T19:52:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T10:48:53.000Z (almost 2 years ago)
- Last Synced: 2024-10-03T12:39:18.834Z (3 months ago)
- Language: Go
- Homepage:
- Size: 237 KB
- Stars: 34
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
- awesome-editorjs - micheleriva/editorjs-go
README
A simple library which converts **[Editor.js](https://editorjs.io)** JSON output to **Markdown** or **HTML**.
## Installation
```bash
go get github.com/micheleriva/editorjs-go
```## Usage
Let's suppose that we have the following Editor.js output saved in a file called `editorjs_output.json`:
```json
{
"blocks": [
{
"type" : "header",
"data" : {
"text" : "Editor.js",
"level" : 2
}
},
{
"type" : "paragraph",
"data" : {
"text" : "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text."
}
}
]
}
``````go
package mainimport (
"fmt"
editorjs "github.com/micheleriva/editorjs-go"
"io/ioutil"
"log"
)func main() {
myJSON, err := ioutil.ReadFile("./editorjs_output.json")
if err != nil {
log.Fatal(err)
}
resultMarkdown := editorjs.Markdown(string(data))
resultHTML := editorjs.HTML(string(data))fmt.Println("=== MARKDOWN ===\n")
fmt.Println(resultMarkdown)fmt.Println("=== HTML ===\n")
fmt.Println(resultHTML)
}
```It will generate the following output:
```
=== MARKDOWN ==="## Editor.js
Hey. Meet the new Editor. On this page you can see it in action — try to edit this text.
=== HTML ===
Editor.js
Hey. Meet the new Editor. On this page you can see it in action — try to edit this text.
```## License
[GPLv3](/LICENSE.md)