diff --git a/.github/workflows/stitchmd.yml b/.github/workflows/stitchmd.yml
new file mode 100644
index 0000000..b8da178
--- /dev/null
+++ b/.github/workflows/stitchmd.yml
@@ -0,0 +1,36 @@
+name: Stitch README.md
+
+on:
+ push:
+ branches: [main]
+
+ # Change the event to pull_request_target
+ # so that it runs in the context of the base repository.
+ pull_request_target:
+
+jobs:
+ stitchmd:
+ name: ${{ github.event_name == 'pull_request_target' && 'Update' || 'Check' }}
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: write
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ ref: ${{ github.head_ref }}
+
+ - name: Check or update README
+ uses: abhinav/stitchmd-action@v1
+ with:
+ mode: ${{ github.event_name == 'pull_request_target' && 'write' || 'check' }}
+ summary: doc/README.md
+ output: README.md
+
+ - uses: stefanzweifel/git-auto-commit-action@v5
+ if: ${{ github.event_name == 'pull_request_target' }}
+ with:
+ file_pattern: README.md
+ commit_message: 'Update README.md'
diff --git a/README.md b/README.md
index 3167dcb..9bfe39a 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,33 @@
# goldmark-mermaid
+- [Introduction](#introduction)
+- [Installation](#installation)
+- [Usage](#usage)
+- [Rendering methods](#rendering-methods)
+- [License](#license)
+
+## Introduction
+
[![Go Reference](https://pkg.go.dev/badge/go.abhg.dev/goldmark/mermaid.svg)](https://pkg.go.dev/go.abhg.dev/goldmark/mermaid)
[![Go](https://github.com/abhinav/goldmark-mermaid/actions/workflows/go.yml/badge.svg)](https://github.com/abhinav/goldmark-mermaid/actions/workflows/go.yml)
[![codecov](https://codecov.io/gh/abhinav/goldmark-mermaid/branch/main/graph/badge.svg?token=W98KYF8SPE)](https://codecov.io/gh/abhinav/goldmark-mermaid)
-goldmark-mermaid is an extension for the [goldmark] Markdown parser that adds
-support for [Mermaid] diagrams.
-
- [goldmark]: http://github.com/yuin/goldmark
- [Mermaid]: https://mermaid-js.github.io/mermaid/
+goldmark-mermaid is an extension for the [goldmark](http://github.com/yuin/goldmark) Markdown parser that adds
+support for [Mermaid](https://mermaid-js.github.io/mermaid/) diagrams.
**Demo**:
A web-based demonstration of the extension is available at
-
+```mermaid +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; +``` +When you render the Markdown as HTML, these will be rendered into diagrams. -## Rendering diagrams +## Rendering methods Mermaid diagrams can be rendered at the time the file is processed ("server-side") @@ -82,3 +94,7 @@ goldmark.New( By default, goldmark-mermaid will pick between the two, based on whether it was able to find the `mmdc` executable on your `$PATH`. + +## License + +This software is made available under the MIT license. diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..fc2c3e4 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,7 @@ +# goldmark-mermaid + +- [Introduction](intro.md) +- [Installation](install.md) +- [Usage](usage.md) +- [Rendering methods](render.md) +- [License](license.md) diff --git a/doc/install.md b/doc/install.md new file mode 100644 index 0000000..6b941d5 --- /dev/null +++ b/doc/install.md @@ -0,0 +1,7 @@ +# Installation + +Install the latest version of the library with Go modules. + +```bash +go get go.abhg.dev/goldmark/mermaid@latest +``` diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..c03fd8c --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,20 @@ +# Introduction + +[![Go Reference](https://pkg.go.dev/badge/go.abhg.dev/goldmark/mermaid.svg)](https://pkg.go.dev/go.abhg.dev/goldmark/mermaid) +[![Go](https://github.com/abhinav/goldmark-mermaid/actions/workflows/go.yml/badge.svg)](https://github.com/abhinav/goldmark-mermaid/actions/workflows/go.yml) +[![codecov](https://codecov.io/gh/abhinav/goldmark-mermaid/branch/main/graph/badge.svg?token=W98KYF8SPE)](https://codecov.io/gh/abhinav/goldmark-mermaid) + +goldmark-mermaid is an extension for the [goldmark] Markdown parser that adds +support for [Mermaid] diagrams. + + [goldmark]: http://github.com/yuin/goldmark + [Mermaid]: https://mermaid-js.github.io/mermaid/ + +**Demo**: +A web-based demonstration of the extension is available at +
+```mermaid +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; +``` ++ +When you render the Markdown as HTML, these will be rendered into diagrams.