Add panel macro

This commit is contained in:
Manuel Rüger 2023-07-05 15:24:18 +02:00
parent 179700f3e4
commit ac982f3077
3 changed files with 22 additions and 5 deletions

View File

@ -439,6 +439,14 @@ By default, mark provides several built-in templates and macros:
* template: `ac:details` to create page properties * template: `ac:details` to create page properties
- Body: Must contain a table with two rows, the table headings are used as property key. The table content is the value. - Body: Must contain a table with two rows, the table headings are used as property key. The table content is the value.
* template: `ac:panel` to display a block of text within a customisable panel
- Title: Panel title (optional)
- Body: Body text of the panel
- BGColor: Background Color
- TitleBGColor: Background color of the title bar
- TitleColor: Text color of the title
- BorderStyle: Style of the panel's border
* macro `@{...}` to mention user by name specified in the braces. * macro `@{...}` to mention user by name specified in the braces.
## Template & Macros Usecases ## Template & Macros Usecases

5
go.sum
View File

@ -2,8 +2,6 @@ github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/cdproto v0.0.0-20230524011726-8501c74e8228 h1:t5YUtCgmUJJ4H5mwQhst70ZxpaCK4SGDtFRPKKw+cYU=
github.com/chromedp/cdproto v0.0.0-20230524011726-8501c74e8228/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/cdproto v0.0.0-20230605001715-1e95ea08ffe6 h1:lH/2I023SRn9+1SaCEQk0iax3HKq8bJ6aj4Iyq4VwjM= github.com/chromedp/cdproto v0.0.0-20230605001715-1e95ea08ffe6 h1:lH/2I023SRn9+1SaCEQk0iax3HKq8bJ6aj4Iyq4VwjM=
github.com/chromedp/cdproto v0.0.0-20230605001715-1e95ea08ffe6/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= github.com/chromedp/cdproto v0.0.0-20230605001715-1e95ea08ffe6/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/chromedp v0.9.1 h1:CC7cC5p1BeLiiS2gfNNPwp3OaUxtRMBjfiw3E3k6dFA= github.com/chromedp/chromedp v0.9.1 h1:CC7cC5p1BeLiiS2gfNNPwp3OaUxtRMBjfiw3E3k6dFA=
@ -16,8 +14,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dreampuf/mermaid.go v0.0.11 h1:XwxrW1TA48qc7Cg1ySvnrMPmap9U2uuvWvc4KuVKVR4=
github.com/dreampuf/mermaid.go v0.0.11/go.mod h1:u9T+LhbKn5d/jC7KzMhncsG/zOfK/14CRFSPbpaGbeI=
github.com/dreampuf/mermaid.go v0.0.12-0.20230620030857-f06bfbab37fc h1:4n1OQw/G+BXtwfni0IWqmmMbRDuyFILBsj3AsohCHxw= github.com/dreampuf/mermaid.go v0.0.12-0.20230620030857-f06bfbab37fc h1:4n1OQw/G+BXtwfni0IWqmmMbRDuyFILBsj3AsohCHxw=
github.com/dreampuf/mermaid.go v0.0.12-0.20230620030857-f06bfbab37fc/go.mod h1:lm0AmK5Gl5nJhHb8geCEbRa53YDoyuYuBibFh108gn4= github.com/dreampuf/mermaid.go v0.0.12-0.20230620030857-f06bfbab37fc/go.mod h1:lm0AmK5Gl5nJhHb8geCEbRa53YDoyuYuBibFh108gn4=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
@ -60,7 +56,6 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=

View File

@ -392,6 +392,20 @@ func templates(api *confluence.API) (*template.Template, error) {
`</ac:structured-macro>`, `</ac:structured-macro>`,
), ),
/* https://confluence.atlassian.com/conf59/panel-macro-792499179.html */
`ac:panel`: text(
`<ac:structured-macro ac:name="panel">`,
`<ac:parameter ac:name="bgColor">{{ or .BGColor "" }}</ac:parameter>`,
`<ac:parameter ac:name="titleBGColor">{{ or .TitleBGColor "" }}</ac:parameter>`,
`<ac:parameter ac:name="title">{{ or .Title "" }}</ac:parameter>`,
`<ac:parameter ac:name="borderStyle">{{ or .BorderStyle "" }}</ac:parameter>`,
`<ac:parameter ac:name="borderColor">{{ or .BorderColor "" }}</ac:parameter>`,
`<ac:parameter ac:name="titleColor">{{ or .TitleColor "" }}</ac:parameter>`,
`<ac:rich-text-body>{{ .Body }}</ac:rich-text-body>`,
`</ac:structured-macro>`,
),
// TODO(seletskiy): more templates here // TODO(seletskiy): more templates here
} { } {
templates, err = templates.New(name).Parse(body) templates, err = templates.New(name).Parse(body)