-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
785 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## Flowchart | ||
```mermaid | ||
--- | ||
title: mermaid flowchart builder | ||
--- | ||
flowchart TB | ||
A["Node A"] | ||
B(["Node B"]) | ||
C[["Node C"]] | ||
D[("Database")] | ||
A-->B | ||
B-->|"send original data"|D | ||
B-->C | ||
C-. "send filtered data" .-> D | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//go:build linux || darwin | ||
|
||
// Package main is generating flowchart. | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
|
||
"github.com/nao1215/markdown" | ||
"github.com/nao1215/markdown/mermaid/flowchart" | ||
) | ||
|
||
//go:generate go run main.go | ||
|
||
func main() { | ||
f, err := os.Create("generated.md") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fc := flowchart.NewFlowchart( | ||
io.Discard, | ||
flowchart.WithTitle("mermaid flowchart builder"), | ||
flowchart.WithOrientalTopToBottom(), | ||
). | ||
NodeWithText("A", "Node A"). | ||
StadiumNode("B", "Node B"). | ||
SubroutineNode("C", "Node C"). | ||
DatabaseNode("D", "Database"). | ||
LinkWithArrowHead("A", "B"). | ||
LinkWithArrowHeadAndText("B", "D", "send original data"). | ||
LinkWithArrowHead("B", "C"). | ||
DottedLinkWithText("C", "D", "send filtered data"). | ||
String() | ||
|
||
err = markdown.NewMarkdown(f). | ||
H2("Flowchart"). | ||
CodeBlocks(markdown.SyntaxHighlightMermaid, fc). | ||
Build() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Package internal package is used to store the internal implementation of the mermaid package. | ||
package internal | ||
|
||
import "runtime" | ||
|
||
// LineFeed return line feed for current OS. | ||
func LineFeed() string { | ||
if runtime.GOOS == "windows" { | ||
return "\r\n" | ||
} | ||
return "\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Package internal package is used to store the internal implementation of the mermaid package. | ||
package internal | ||
|
||
import ( | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func TestLineFeed(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("should return line feed for current OS", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
got := LineFeed() | ||
|
||
switch runtime.GOOS { | ||
case "windows": | ||
if got != "\r\n" { | ||
t.Errorf("expected \\r\\n, but got %s", got) | ||
} | ||
default: | ||
if got != "\n" { | ||
t.Errorf("expected \\n, but got %s", got) | ||
} | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.