Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,21 @@ All you need is a codeblock marked as "d2".
X -> Y
```

### Render PlantUML Diagram

Mark supports [PlantUML](https://plantuml.com/) diagrams using the [Confluence PlantUML macro](https://avono-support.atlassian.net/wiki/spaces/PUML/pages/9699367/Macro+plantuml). This feature is enabled by default.

When you include a code block marked as "plantuml", mark will wrap it in the appropriate Confluence macro, allowing the PlantUML plugin in Confluence to render the diagram.

**Note:** This requires the PlantUML plugin to be installed in your Confluence instance.

```plantuml
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
```

### MkDocs' Admonitions

Optionally you can enable mkdocs-style [Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/) via `--features="mkdocsadmonitions"`.
Expand Down Expand Up @@ -842,7 +857,7 @@ GLOBAL OPTIONS:
--include-path string Path for shared includes, used as a fallback if the include doesn't exist in the current directory. [$MARK_INCLUDE_PATH]
--changes-only Avoids re-uploading pages that haven't changed since the last run. [$MARK_CHANGES_ONLY]
--d2-scale float defines the scaling factor for d2 renderings. (default: 1) [$MARK_D2_SCALE]
--features string [ --features string ] Enables optional features. Current features: d2, mermaid, mention, mkdocsadmonitions (default: "mermaid", "mention") [$MARK_FEATURES]
--features string [ --features string ] Enables optional features. Current features: d2, mermaid, mention, mkdocsadmonitions, plantuml (default: "mermaid", "mention", "plantuml") [$MARK_FEATURES]
--insecure-skip-tls-verify skip TLS certificate verification (useful for self-signed certificates) [$MARK_INSECURE_SKIP_TLS_VERIFY]
--help, -h show help
--version, -v print the version
Expand Down
8 changes: 4 additions & 4 deletions markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestCompileMarkdown(t *testing.T) {
D2Scale: 1.0,
DropFirstH1: false,
StripNewlines: false,
Features: []string{"mkdocsadmonitions", "mention"},
Features: []string{"mkdocsadmonitions", "mention", "plantuml"},
}

actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestCompileMarkdownDropH1(t *testing.T) {
}
var variant string
switch filename {
case "testdata/quotes.md", "testdata/header.md", "testdata/admonitions.md":
case "testdata/quotes.md", "testdata/header.md", "testdata/admonitions.md", "testdata/plantuml.md":
variant = "-droph1"
default:
variant = ""
Expand All @@ -106,7 +106,7 @@ func TestCompileMarkdownDropH1(t *testing.T) {
D2Scale: 1.0,
DropFirstH1: true,
StripNewlines: false,
Features: []string{"mkdocsadmonitions", "mention"},
Features: []string{"mkdocsadmonitions", "mention", "plantuml"},
}

actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestCompileMarkdownStripNewlines(t *testing.T) {
D2Scale: 1.0,
DropFirstH1: false,
StripNewlines: true,
Features: []string{"mkdocsadmonitions", "mention"},
Features: []string{"mkdocsadmonitions", "mention", "plantuml"},
}

actual, _ := mark.CompileMarkdown(markdown, lib, filename, cfg)
Expand Down
15 changes: 15 additions & 0 deletions renderer/fencedcodeblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ func (r *ConfluenceFencedCodeBlockRenderer) renderFencedCodeBlock(writer util.Bu
return ast.WalkStop, err
}

} else if lang == "plantuml" && slices.Contains(r.MarkConfig.Features, "plantuml") {
err := r.Stdlib.Templates.ExecuteTemplate(
writer,
"ac:plantuml",
struct {
Text string
}{
strings.TrimSuffix(string(lval), "\n"),
},
)

if err != nil {
return ast.WalkStop, err
}

} else {
err := r.Stdlib.Templates.ExecuteTemplate(
writer,
Expand Down
7 changes: 7 additions & 0 deletions stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ func templates(api *confluence.API) (*template.Template, error) {
`</ac:structured-macro>`,
),

// This template is used for rendering PlantUML diagrams
`ac:plantuml`: text(
`<ac:structured-macro ac:name="plantuml">`,
/**/ `<ac:plain-text-body><![CDATA[{{ .Text | cdata }}]]></ac:plain-text-body>`,
`</ac:structured-macro>`,
),

`ac:status`: text(
`<ac:structured-macro ac:name="status">`,
`<ac:parameter ac:name="colour">{{ or .Color "Grey" }}</ac:parameter>`,
Expand Down
22 changes: 22 additions & 0 deletions testdata/plantuml-droph1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>A simple PlantUML diagram:</p>
<ac:structured-macro ac:name="plantuml"><ac:plain-text-body><![CDATA[@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml]]></ac:plain-text-body></ac:structured-macro><p>Another diagram with more complex syntax:</p>
<ac:structured-macro ac:name="plantuml"><ac:plain-text-body><![CDATA[@startuml
participant Participant as Foo
actor Actor as Foo1
boundary Boundary as Foo2
control Control as Foo3
entity Entity as Foo4
database Database as Foo5
collections Collections as Foo6
queue Queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
@enduml]]></ac:plain-text-body></ac:structured-macro>
23 changes: 23 additions & 0 deletions testdata/plantuml.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1 id="PlantUML-Test">PlantUML Test</h1>
<p>A simple PlantUML diagram:</p>
<ac:structured-macro ac:name="plantuml"><ac:plain-text-body><![CDATA[@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml]]></ac:plain-text-body></ac:structured-macro><p>Another diagram with more complex syntax:</p>
<ac:structured-macro ac:name="plantuml"><ac:plain-text-body><![CDATA[@startuml
participant Participant as Foo
actor Actor as Foo1
boundary Boundary as Foo2
control Control as Foo3
entity Entity as Foo4
database Database as Foo5
collections Collections as Foo6
queue Queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
@enduml]]></ac:plain-text-body></ac:structured-macro>
32 changes: 32 additions & 0 deletions testdata/plantuml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# PlantUML Test

A simple PlantUML diagram:

```plantuml
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml
```

Another diagram with more complex syntax:

```plantuml
@startuml
participant Participant as Foo
actor Actor as Foo1
boundary Boundary as Foo2
control Control as Foo3
entity Entity as Foo4
database Database as Foo5
collections Collections as Foo6
queue Queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
@enduml
```
4 changes: 2 additions & 2 deletions util/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ var Flags = []cli.Flag{

&cli.StringSliceFlag{
Name: "features",
Value: []string{"mermaid", "mention"},
Usage: "Enables optional features. Current features: d2, mermaid, mention, mkdocsadmonitions",
Value: []string{"mermaid", "mention", "plantuml"},
Usage: "Enables optional features. Current features: d2, mermaid, mention, mkdocsadmonitions, plantuml",
Sources: cli.NewValueSourceChain(cli.EnvVar("MARK_FEATURES"), altsrctoml.TOML("features", altsrc.NewStringPtrSourcer(&filename))),
},
&cli.BoolFlag{
Expand Down
Loading