{"id":17882130,"url":"https://github.com/nao1215/markdown","last_synced_at":"2025-04-06T13:09:21.158Z","repository":{"id":202780990,"uuid":"707965077","full_name":"nao1215/markdown","owner":"nao1215","description":"simple markdown \u0026 mermaid builder in golang","archived":false,"fork":false,"pushed_at":"2025-02-24T23:45:03.000Z","size":650,"stargazers_count":90,"open_issues_count":3,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T12:07:13.753Z","etag":null,"topics":["builder","entity-relationship-diagram","golang","markdown","markdown-buider","mermaid","pie-chart","sequence-diagram"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nao1215.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nao1215"}},"created_at":"2023-10-21T05:40:31.000Z","updated_at":"2025-03-27T12:30:33.000Z","dependencies_parsed_at":"2023-10-28T06:25:06.222Z","dependency_job_id":"b50ffda7-3830-4d65-b73c-ab22ccb63c82","html_url":"https://github.com/nao1215/markdown","commit_stats":{"total_commits":74,"total_committers":7,"mean_commits":"10.571428571428571","dds":"0.16216216216216217","last_synced_commit":"230605e12fdffea88e541b4c54dff5c9d7133d96"},"previous_names":["go-spectest/markdown"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fmarkdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fmarkdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fmarkdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nao1215%2Fmarkdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nao1215","download_url":"https://codeload.github.com/nao1215/markdown/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485287,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder","entity-relationship-diagram","golang","markdown","markdown-buider","mermaid","pie-chart","sequence-diagram"],"created_at":"2024-10-28T12:48:15.360Z","updated_at":"2025-04-06T13:09:21.121Z","avatar_url":"https://github.com/nao1215.png","language":"Go","funding_links":["https://github.com/sponsors/nao1215"],"categories":[],"sub_categories":[],"readme":"\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n[![Go Reference](https://pkg.go.dev/badge/github.com/nao1215/markdown.svg)](https://pkg.go.dev/github.com/nao1215/markdown)\n[![MultiPlatformUnitTest](https://github.com/nao1215/markdown/actions/workflows/unit_test.yml/badge.svg)](https://github.com/nao1215/markdown/actions/workflows/unit_test.yml)\n[![reviewdog](https://github.com/nao1215/markdown/actions/workflows/reviewdog.yml/badge.svg)](https://github.com/nao1215/markdown/actions/workflows/reviewdog.yml)\n[![Gosec](https://github.com/nao1215/markdown/actions/workflows/gosec.yml/badge.svg)](https://github.com/nao1215/markdown/actions/workflows/gosec.yml)\n![Coverage](https://raw.githubusercontent.com/nao1215/octocovs-central-repo/main/badges/nao1215/markdown/coverage.svg)\n# What is markdown package\nThe Package markdown is a simple markdown builder in golang. The markdown package assembles Markdown using method chaining, not uses a template engine like [html/template](https://pkg.go.dev/html/template). The syntax of Markdown follows **GitHub Markdown**.\n  \nThe markdown package was initially developed to save test results in [nao1215/spectest](https://github.com/nao1215/spectest). Therefore, the markdown package implements the features required by spectest. For example, the markdown package supports **mermaid sequence diagrams (entity relationship diagram, sequence diagram, flowchart, pie chart, architecture diagram)**, which was a necessary feature in spectest.\n  \nAdditionally, complex code that increases the complexity of the library, such as generating nested lists, will not be added. I want to keep this library as simple as possible.\n  \n## Supported OS and go version\n- OS: Linux, macOS, Windows\n- Go: 1.21 or later\n  \n## Supported Markdown features\n- [x] Heading; H1, H2, H3, H4, H5, H6\n- [x] Blockquote \n- [x] Bullet list\n- [x] Ordered list\n- [x] Checkbox list \n- [x] Code blocks\n- [x] Horizontal rule \n- [x] Table\n- [x] Text formatting; bold, italic, code, strikethrough, bold italic\n- [x] Text with link\n- [x] Text with image\n- [x] Plain text\n- [x] Details \n- [x] Alerts; NOTE, TIP, IMPORTANT, CAUTION, WARNING\n- [x] mermaid sequence diagram\n- [x] mermaid entity relationship diagram\n- [x] mermaid flowchart \n- [x] mermaid pie chart\n- [x] mermaid architecture diagram (beta feature) \n\n### Features not in Markdown syntax\n- Generate badges; RedBadge(), YellowBadge(), GreenBadge().\n- Generate an index for a directory full of markdown files; GenerateIndex()\n  \n## Example\n### Basic usage\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\tmd \"github.com/nao1215/markdown\"\n)\n\nfunc main() {\n\tmd.NewMarkdown(os.Stdout).\n\t\tH1(\"This is H1\").\n\t\tPlainText(\"This is plain text\").\n\t\tH2f(\"This is %s with text format\", \"H2\").\n\t\tPlainTextf(\"Text formatting, such as %s and %s, %s styles.\",\n\t\t\tmd.Bold(\"bold\"), md.Italic(\"italic\"), md.Code(\"code\")).\n\t\tH2(\"Code Block\").\n\t\tCodeBlocks(md.SyntaxHighlightGo,\n\t\t\t`package main\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"Hello, World!\")\n}`).\n\t\tH2(\"List\").\n\t\tBulletList(\"Bullet Item 1\", \"Bullet Item 2\", \"Bullet Item 3\").\n\t\tOrderedList(\"Ordered Item 1\", \"Ordered Item 2\", \"Ordered Item 3\").\n\t\tH2(\"CheckBox\").\n\t\tCheckBox([]md.CheckBoxSet{\n\t\t\t{Checked: false, Text: md.Code(\"sample code\")},\n\t\t\t{Checked: true, Text: md.Link(\"Go\", \"https://golang.org\")},\n\t\t\t{Checked: false, Text: md.Strikethrough(\"strikethrough\")},\n\t\t}).\n\t\tH2(\"Blockquote\").\n\t\tBlockquote(\"If you can dream it, you can do it.\").\n\t\tH3(\"Horizontal Rule\").\n\t\tHorizontalRule().\n\t\tH2(\"Table\").\n\t\tTable(md.TableSet{\n\t\t\tHeader: []string{\"Name\", \"Age\", \"Country\"},\n\t\t\tRows: [][]string{\n\t\t\t\t{\"David\", \"23\", \"USA\"},\n\t\t\t\t{\"John\", \"30\", \"UK\"},\n\t\t\t\t{\"Bob\", \"25\", \"Canada\"},\n\t\t\t},\n\t\t}).\n\t\tH2(\"Image\").\n\t\tPlainTextf(md.Image(\"sample_image\", \"./sample.png\")).\n\t\tBuild()\n}\n```\n\nOutput:\n````\n# This is H1\nThis is plain text\n  \n## This is H2 with text format\nText formatting, such as **bold** and *italic*, `code` styles.\n  \n## Code Block\n```go\npackage main\nimport \"fmt\"\n\nfunc main() {\n        fmt.Println(\"Hello, World!\")\n}\n```\n  \n## List\n- Bullet Item 1\n- Bullet Item 2\n- Bullet Item 3\n1. Ordered Item 1\n2. Ordered Item 2\n3. Ordered Item 3\n  \n## CheckBox\n- [ ] `sample code`\n- [x] [Go](https://golang.org)\n- [ ] ~~strikethrough~~\n  \n## Blockquote\n\u003e If you can dream it, you can do it.\n  \n### Horizontal Rule\n---\n  \n## Table\n| NAME  | AGE | COUNTRY |\n|-------|-----|---------|\n| David |  23 | USA     |\n| John  |  30 | UK      |\n| Bob   |  25 | Canada  |\n\n## Image\n![sample_image](./sample.png)\n````\n\nIf you want to see how it looks in Markdown, please refer to the following link.\n- [sample.md](./doc/generated_example.md)\n\n### Generate Markdown using `\"go generate ./...\"`\nYou can generate Markdown using `go generate`. Please define code to generate Markdown first. Then, run `\"go generate ./...\"` to generate Markdown.\n\n[Code example:](./doc/generate/main.go)\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\tmd \"github.com/nao1215/markdown\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tf, err := os.Create(\"generated.md\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\tmd.NewMarkdown(f).\n\t\tH1(\"go generate example\").\n\t\tPlainText(\"This markdown is generated by `go generate`\").\n\t\tBuild()\n}\n```\n\nRun below command:\n```shell\ngo generate ./...\n```\n\n[Output:](./doc/generate/generated.md)\n````text\n# go generate example\nThis markdown is generated by `go generate`\n````\n\n### Alerts syntax\nThe markdown package can create alerts. Alerts are useful for displaying important information in Markdown. This syntax is supported by GitHub.\n[Code example:](./doc/alert/main.go)\n```go\n\tmd.NewMarkdown(f).\n\t\tH1(\"Alert example\").\n\t\tNote(\"This is note\").LF().\n\t\tTip(\"This is tip\").LF().\n\t\tImportant(\"This is important\").LF().\n\t\tWarning(\"This is warning\").LF().\n\t\tCaution(\"This is caution\").LF().\n\t\tBuild()\n```\n  \n[Output:](./doc/alert/generated.md)\n````text\n# Alert example\n\u003e [!NOTE]  \n\u003e This is note\n  \n\u003e [!TIP]  \n\u003e This is tip\n  \n\u003e [!IMPORTANT]  \n\u003e This is important\n  \n\u003e [!WARNING]  \n\u003e This is warning\n  \n\u003e [!CAUTION]  \n\u003e This is caution\n````\n\nYour alert will look like this;\n\u003e [!NOTE]  \n\u003e This is note\n  \n\u003e [!TIP]  \n\u003e This is tip\n  \n\u003e [!IMPORTANT]  \n\u003e This is important\n  \n\u003e [!WARNING]  \n\u003e This is warning\n  \n\u003e [!CAUTION]  \n\u003e This is caution\n\n### Status badge syntax\nThe markdown package can create red, yellow, and green status badges.\n[Code example:](./doc/badge/main.go)\n```go\n\tmd.NewMarkdown(os.Stdout).\n\t\tH1(\"badge example\").\n\t\tRedBadge(\"red_badge\").\n\t\tYellowBadge(\"yellow_badge\").\n\t\tGreenBadge(\"green_badge\").\n\t\tBlueBadge(\"blue_badge\").\n\t\tBuild()\n```\n\n[Output:](./doc/badge/generated.md)\n````text\n# badge example\n![Badge](https://img.shields.io/badge/red_badge-red)\n![Badge](https://img.shields.io/badge/yellow_badge-yellow)\n![Badge](https://img.shields.io/badge/green_badge-green)\n![Badge](https://img.shields.io/badge/blue_badge-blue)\n````\n\nYour badge will look like this;  \n![Badge](https://img.shields.io/badge/red_badge-red)\n![Badge](https://img.shields.io/badge/yellow_badge-yellow)\n![Badge](https://img.shields.io/badge/green_badge-green)\n![Badge](https://img.shields.io/badge/blue_badge-blue)\n\n### Mermaid sequence diagram syntax\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/nao1215/markdown\"\n\t\"github.com/nao1215/mermaid/sequence\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tdiagram := sequence.NewDiagram(io.Discard).\n\t\tParticipant(\"Sophia\").\n\t\tParticipant(\"David\").\n\t\tParticipant(\"Subaru\").\n\t\tLF().\n\t\tSyncRequest(\"Sophia\", \"David\", \"Please wake up Subaru\").\n\t\tSyncResponse(\"David\", \"Sophia\", \"OK\").\n\t\tLF().\n\t\tLoopStart(\"until Subaru wake up\").\n\t\tSyncRequest(\"David\", \"Subaru\", \"Wake up!\").\n\t\tSyncResponse(\"Subaru\", \"David\", \"zzz\").\n\t\tSyncRequest(\"David\", \"Subaru\", \"Hey!!!\").\n\t\tBreakStart(\"if Subaru wake up\").\n\t\tSyncResponse(\"Subaru\", \"David\", \"......\").\n\t\tBreakEnd().\n\t\tLoopEnd().\n\t\tLF().\n\t\tSyncResponse(\"David\", \"Sophia\", \"wake up, wake up\").\n\t\tString()\n\n\tmarkdown.NewMarkdown(os.Stdout).\n\t\tH2(\"Sequence Diagram\").\n\t\tCodeBlocks(markdown.SyntaxHighlightMermaid, diagram).\n\t\tBuild()\n}\n```\n\nPlain text output: [markdown is here](./doc/sequence/generated.md)\n````\n## Sequence Diagram\n```mermaid\nsequenceDiagram\n    participant Sophia\n    participant David\n    participant Subaru\n\n    Sophia-\u003e\u003eDavid: Please wake up Subaru\n    David--\u003e\u003eSophia: OK\n\n    loop until Subaru wake up\n    David-\u003e\u003eSubaru: Wake up!\n    Subaru--\u003e\u003eDavid: zzz\n    David-\u003e\u003eSubaru: Hey!!!\n    break if Subaru wake up\n    Subaru--\u003e\u003eDavid: ......\n    end\n    end\n\n    David--\u003e\u003eSophia: wake up, wake up\n```\n````\n\nMermaid output:\n```mermaid\nsequenceDiagram\n    participant Sophia\n    participant David\n    participant Subaru\n\n    Sophia-\u003e\u003eDavid: Please wake up Subaru\n    David--\u003e\u003eSophia: OK\n\n    loop until Subaru wake up\n    David-\u003e\u003eSubaru: Wake up!\n    Subaru--\u003e\u003eDavid: zzz\n    David-\u003e\u003eSubaru: Hey!!!\n    break if Subaru wake up\n    Subaru--\u003e\u003eDavid: ......\n    end\n    end\n\n    David--\u003e\u003eSophia: wake up, wake up\n```\n\n### Entity Relationship Diagram syntax\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/nao1215/markdown\"\n\t\"github.com/nao1215/markdown/mermaid/er\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tf, err := os.Create(\"generated.md\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\tteachers := er.NewEntity(\n\t\t\"teachers\",\n\t\t[]*er.Attribute{\n\t\t\t{\n\t\t\t\tType:         \"int\",\n\t\t\t\tName:         \"id\",\n\t\t\t\tIsPrimaryKey: true,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  true,\n\t\t\t\tComment:      \"Teacher ID\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tType:         \"string\",\n\t\t\t\tName:         \"name\",\n\t\t\t\tIsPrimaryKey: false,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  false,\n\t\t\t\tComment:      \"Teacher Name\",\n\t\t\t},\n\t\t},\n\t)\n\tstudents := er.NewEntity(\n\t\t\"students\",\n\t\t[]*er.Attribute{\n\t\t\t{\n\t\t\t\tType:         \"int\",\n\t\t\t\tName:         \"id\",\n\t\t\t\tIsPrimaryKey: true,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  true,\n\t\t\t\tComment:      \"Student ID\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tType:         \"string\",\n\t\t\t\tName:         \"name\",\n\t\t\t\tIsPrimaryKey: false,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  false,\n\t\t\t\tComment:      \"Student Name\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tType:         \"int\",\n\t\t\t\tName:         \"teacher_id\",\n\t\t\t\tIsPrimaryKey: false,\n\t\t\t\tIsForeignKey: true,\n\t\t\t\tIsUniqueKey:  true,\n\t\t\t\tComment:      \"Teacher ID\",\n\t\t\t},\n\t\t},\n\t)\n\tschools := er.NewEntity(\n\t\t\"schools\",\n\t\t[]*er.Attribute{\n\t\t\t{\n\t\t\t\tType:         \"int\",\n\t\t\t\tName:         \"id\",\n\t\t\t\tIsPrimaryKey: true,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  true,\n\t\t\t\tComment:      \"School ID\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tType:         \"string\",\n\t\t\t\tName:         \"name\",\n\t\t\t\tIsPrimaryKey: false,\n\t\t\t\tIsForeignKey: false,\n\t\t\t\tIsUniqueKey:  false,\n\t\t\t\tComment:      \"School Name\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tType:         \"int\",\n\t\t\t\tName:         \"teacher_id\",\n\t\t\t\tIsPrimaryKey: false,\n\t\t\t\tIsForeignKey: true,\n\t\t\t\tIsUniqueKey:  true,\n\t\t\t\tComment:      \"Teacher ID\",\n\t\t\t},\n\t\t},\n\t)\n\n\terString := er.NewDiagram(f).\n\t\tRelationship(\n\t\t\tteachers,\n\t\t\tstudents,\n\t\t\ter.ExactlyOneRelationship, // \"||\"\n\t\t\ter.ZeroToMoreRelationship, // \"}o\"\n\t\t\ter.Identifying,            // \"--\"\n\t\t\t\"Teacher has many students\",\n\t\t).\n\t\tRelationship(\n\t\t\tteachers,\n\t\t\tschools,\n\t\t\ter.OneToMoreRelationship,  // \"|}\"\n\t\t\ter.ExactlyOneRelationship, // \"||\"\n\t\t\ter.NonIdentifying,         // \"..\"\n\t\t\t\"School has many teachers\",\n\t\t).\n\t\tString()\n\n\terr = markdown.NewMarkdown(f).\n\t\tH2(\"Entity Relationship Diagram\").\n\t\tCodeBlocks(markdown.SyntaxHighlightMermaid, erString).\n\t\tBuild()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nPlain text output: [markdown is here](./doc/er/generated.md)\n````\n## Entity Relationship Diagram\n```mermaid\nerDiagram\n\tteachers ||--o{ students : \"Teacher has many students\"\n\tteachers }|..|| schools : \"School has many teachers\"\n\tschools {\n\t\tint id PK,UK \"School ID\"\n\t\tstring name  \"School Name\"\n\t\tint teacher_id FK,UK \"Teacher ID\"\n\t}\n\tstudents {\n\t\tint id PK,UK \"Student ID\"\n\t\tstring name  \"Student Name\"\n\t\tint teacher_id FK,UK \"Teacher ID\"\n\t}\n\tteachers {\n\t\tint id PK,UK \"Teacher ID\"\n\t\tstring name  \"Teacher Name\"\n\t}\n\n```\n````\n\nMermaid output:\n```mermaid\nerDiagram\n\tteachers ||--o{ students : \"Teacher has many students\"\n\tteachers }|..|| schools : \"School has many teachers\"\n\tschools {\n\t\tint id PK,UK \"School ID\"\n\t\tstring name  \"School Name\"\n\t\tint teacher_id FK,UK \"Teacher ID\"\n\t}\n\tstudents {\n\t\tint id PK,UK \"Student ID\"\n\t\tstring name  \"Student Name\"\n\t\tint teacher_id FK,UK \"Teacher ID\"\n\t}\n\tteachers {\n\t\tint id PK,UK \"Teacher ID\"\n\t\tstring name  \"Teacher Name\"\n\t}\n```\n\n### Flowchart syntax\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/nao1215/markdown\"\n\t\"github.com/nao1215/markdown/mermaid/flowchart\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tf, err := os.Create(\"generated.md\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\tfc := flowchart.NewFlowchart(\n\t\tio.Discard,\n\t\tflowchart.WithTitle(\"mermaid flowchart builder\"),\n\t\tflowchart.WithOrientalTopToBottom(),\n\t).\n\t\tNodeWithText(\"A\", \"Node A\").\n\t\tStadiumNode(\"B\", \"Node B\").\n\t\tSubroutineNode(\"C\", \"Node C\").\n\t\tDatabaseNode(\"D\", \"Database\").\n\t\tLinkWithArrowHead(\"A\", \"B\").\n\t\tLinkWithArrowHeadAndText(\"B\", \"D\", \"send original data\").\n\t\tLinkWithArrowHead(\"B\", \"C\").\n\t\tDottedLinkWithText(\"C\", \"D\", \"send filtered data\").\n\t\tString()\n\n\terr = markdown.NewMarkdown(f).\n\t\tH2(\"Flowchart\").\n\t\tCodeBlocks(markdown.SyntaxHighlightMermaid, fc).\n\t\tBuild()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nPlain text output: [markdown is here](./doc/flowchart/generated.md)\n````\n## Flowchart\n```mermaid\n---\ntitle: mermaid flowchart builder\n---\nflowchart TB\n\tA[\"Node A\"]\n\tB([\"Node B\"])\n\tC[[\"Node C\"]]\n\tD[(\"Database\")]\n\tA--\u003eB\n\tB--\u003e|\"send original data\"|D\n\tB--\u003eC\n\tC-. \"send filtered data\" .-\u003e D\n```\n````\n\nMermaid output:\n```mermaid\nflowchart TB\n\tA[\"Node A\"]\n\tB([\"Node B\"])\n\tC[[\"Node C\"]]\n\tD[(\"Database\")]\n\tA--\u003eB\n\tB--\u003e|\"send original data\"|D\n\tB--\u003eC\n\tC-. \"send filtered data\" .-\u003e D\n```\n\n### Pie chart syntax\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/nao1215/markdown\"\n\t\"github.com/nao1215/markdown/mermaid/piechart\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tf, err := os.Create(\"generated.md\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\tchart := piechart.NewPieChart(\n\t\tio.Discard,\n\t\tpiechart.WithTitle(\"mermaid pie chart builder\"),\n\t\tpiechart.WithShowData(true),\n\t).\n\t\tLabelAndIntValue(\"A\", 10).\n\t\tLabelAndFloatValue(\"B\", 20.1).\n\t\tLabelAndIntValue(\"C\", 30).\n\t\tString()\n\n\terr = markdown.NewMarkdown(f).\n\t\tH2(\"Pie Chart\").\n\t\tCodeBlocks(markdown.SyntaxHighlightMermaid, chart).\n\t\tBuild()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nPlain text output: [markdown is here](./doc/piechart/generated.md)\n````\n## Pie Chart\n```mermaid\n%%{init: {\"pie\": {\"textPosition\": 0.75}, \"themeVariables\": {\"pieOuterStrokeWidth\": \"5px\"}} }%%\npie showData\n    title mermaid pie chart builder\n    \"A\" : 10\n    \"B\" : 20.100000\n    \"C\" : 30\n```\n````\n\nMermaid output:\n```mermaid\n%%{init: {\"pie\": {\"textPosition\": 0.75}, \"themeVariables\": {\"pieOuterStrokeWidth\": \"5px\"}} }%%\npie showData\n    title mermaid pie chart builder\n    \"A\" : 10\n    \"B\" : 20.100000\n    \"C\" : 30\n```\n\n### Architecture Diagrams (beta feature)\n\n[The mermaid provides a feature to visualize infrastructure architecture as a beta version](https://mermaid.js.org/syntax/architecture.html), and that feature has been introduced.\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/nao1215/markdown\"\n\t\"github.com/nao1215/markdown/mermaid/arch\"\n)\n\n//go:generate go run main.go\n\nfunc main() {\n\tf, err := os.Create(\"generated.md\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\tdiagram := arch.NewArchitecture(io.Discard).\n\t\tService(\"left_disk\", arch.IconDisk, \"Disk\").\n\t\tService(\"top_disk\", arch.IconDisk, \"Disk\").\n\t\tService(\"bottom_disk\", arch.IconDisk, \"Disk\").\n\t\tService(\"top_gateway\", arch.IconInternet, \"Gateway\").\n\t\tService(\"bottom_gateway\", arch.IconInternet, \"Gateway\").\n\t\tJunction(\"junctionCenter\").\n\t\tJunction(\"junctionRight\").\n\t\tLF().\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"left_disk\",\n\t\t\t\tPosition:  arch.PositionRight,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionCenter\",\n\t\t\t\tPosition:  arch.PositionLeft,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"top_disk\",\n\t\t\t\tPosition:  arch.PositionBottom,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionCenter\",\n\t\t\t\tPosition:  arch.PositionTop,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"bottom_disk\",\n\t\t\t\tPosition:  arch.PositionTop,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionCenter\",\n\t\t\t\tPosition:  arch.PositionBottom,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionCenter\",\n\t\t\t\tPosition:  arch.PositionRight,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionRight\",\n\t\t\t\tPosition:  arch.PositionLeft,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"top_gateway\",\n\t\t\t\tPosition:  arch.PositionBottom,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionRight\",\n\t\t\t\tPosition:  arch.PositionTop,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).\n\t\tEdges(\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"bottom_gateway\",\n\t\t\t\tPosition:  arch.PositionTop,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t},\n\t\t\tarch.Edge{\n\t\t\t\tServiceID: \"junctionRight\",\n\t\t\t\tPosition:  arch.PositionBottom,\n\t\t\t\tArrow:     arch.ArrowNone,\n\t\t\t}).String() //nolint\n\n\terr = markdown.NewMarkdown(f).\n\t\tH2(\"Architecture Diagram\").\n\t\tCodeBlocks(markdown.SyntaxHighlightMermaid, diagram).\n\t\tBuild()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n```\n\nPlain text output: [markdown is here](./doc/architecture/generated.md)\n````\n## Architecture Diagram\n```mermaid\narchitecture-beta\n    service left_disk(disk)[Disk]\n    service top_disk(disk)[Disk]\n    service bottom_disk(disk)[Disk]\n    service top_gateway(internet)[Gateway]\n    service bottom_gateway(internet)[Gateway]\n    junction junctionCenter\n    junction junctionRight\n\n    left_disk:R -- L:junctionCenter\n    top_disk:B -- T:junctionCenter\n    bottom_disk:T -- B:junctionCenter\n    junctionCenter:R -- L:junctionRight\n    top_gateway:B -- T:junctionRight\n    bottom_gateway:T -- B:junctionRight\n```\n````\n\n![Architecture Diagram](./doc/architecture/image.png)\n\n## Creating an index for a directory full of markdown files\nThe markdown package can create an index for Markdown files within the specified directory. This feature was added to generate indexes for Markdown documents produced by [nao1215/spectest](https://github.com/nao1215/spectest).\n  \nFor example, consider the following directory structure:\n\n```shell\ntestdata\n├── abc\n│   ├── dummy.txt\n│   ├── jkl\n│   │   └── text.md\n│   └── test.md\n├── def\n│   ├── test.md\n│   └── test2.md\n├── expected\n│   └── index.md\n├── ghi\n└── test.md\n```\n  \nIn the following implementation, it creates an index markdown file containing links to all markdown files located within the testdata directory.\n\n```go\n\t\tif err := GenerateIndex(\n\t\t\t\"testdata\", // target directory that contains markdown files\n\t\t\tWithTitle(\"Test Title\"), // title of index markdown\n\t\t\tWithDescription([]string{\"Test Description\", \"Next Description\"}), // description of index markdown\n\t\t); err != nil {\n\t\t\tpanic(err)\n\t\t}\n```\n  \nThe index Markdown file is created under \"target directory/index.md\" by default. If you want to change this path, please use the `WithWriter()` option. The link names in the file will be the first occurrence of H1 or H2 in the target Markdown. If neither H1 nor H2 is present, the link name will be the file name of the destination.  \n  \n[Output:](./doc/index.md)\n```markdown\n## Test Title\nTest Description\n  \nNext Description\n  \n### testdata\n- [test.md](test.md)\n  \n### abc\n- [h2 is here](abc/test.md)\n  \n### jkl\n- [text.md](abc/jkl/text.md)\n  \n### def\n- [h2 is first, not h1](def/test.md)\n- [h1 is here](def/test2.md)\n  \n### expected\n- [Test Title](expected/index.md)\n```\n  \n## License\n[MIT License](./LICENSE)\n\n## Contribution\nFirst off, thanks for taking the time to contribute! See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information. Contributions are not only related to development. For example, GitHub Star motivates me to develop! Please feel free to contribute to this project.\n\n[![Star History Chart](https://api.star-history.com/svg?repos=nao1215/markdown\u0026type=Date)](https://star-history.com/#nao1215/markdown\u0026Date)\n\n### Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://debimate.jp/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/22737008?v=4?s=50\" width=\"50px;\" alt=\"CHIKAMATSU Naohiro\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eCHIKAMATSU Naohiro\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/markdown/commits?author=nao1215\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/varmakarthik12\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/17958166?v=4?s=50\" width=\"50px;\" alt=\"Karthik Sundari\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKarthik Sundari\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/markdown/commits?author=varmakarthik12\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/Avihuc\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/32455410?v=4?s=50\" width=\"50px;\" alt=\"Avihuc\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAvihuc\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/markdown/commits?author=Avihuc\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://www.claranceliberi.me/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/60586899?v=4?s=50\" width=\"50px;\" alt=\"Clarance Liberiste Ntwari\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eClarance Liberiste Ntwari\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/markdown/commits?author=claranceliberi\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/amitaifrey\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/7527632?v=4?s=50\" width=\"50px;\" alt=\"Amitai Frey\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAmitai Frey\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/nao1215/markdown/commits?author=amitaifrey\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n  \u003ctfoot\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" size=\"13px\" colspan=\"7\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg\"\u003e\n          \u003ca href=\"https://all-contributors.js.org/docs/en/bot/usage\"\u003eAdd your contributions\u003c/a\u003e\n        \u003c/img\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tfoot\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fmarkdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnao1215%2Fmarkdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnao1215%2Fmarkdown/lists"}