diff --git a/pkg/mark/stdlib/stdlib.go b/pkg/mark/stdlib/stdlib.go index 2025492..4ef4a59 100644 --- a/pkg/mark/stdlib/stdlib.go +++ b/pkg/mark/stdlib/stdlib.go @@ -113,15 +113,15 @@ func templates(api *confluence.API) (*template.Template, error) { // This template is used for rendering code in ``` `ac:code`: text( - `{{printf "\n"}}`, - /**/ `{{ if eq .Language "mermaid" }}true{{printf "\n"}}{{ else }}`, - /**/ `{{ .Language }}{{printf "\n"}}{{ end }}`, - /**/ `{{ .Collapse }}{{printf "\n"}}`, - /**/ `{{ if .Theme }}{{ .Theme }}{{printf "\n"}}{{ end }}`, - /**/ `{{ if .Linenumbers }}{{ .Linenumbers }}{{printf "\n"}}{{ end }}`, - /**/ `{{ if .Firstline }}{{ .Firstline }}{{printf "\n"}}{{ end }}`, - /**/ `{{ if .Title }}{{ .Title }}{{printf "\n"}}{{ end }}`, - /**/ `{{printf "\n"}}`, + ``, + /**/ `{{ if eq .Language "mermaid" }}true{{ else }}`, + /**/ `{{ .Language }}{{ end }}`, + /**/ `{{ .Collapse }}`, + /**/ `{{ if .Theme }}{{ .Theme }}{{ end }}`, + /**/ `{{ if .Linenumbers }}{{ .Linenumbers }}{{ end }}`, + /**/ `{{ if .Firstline }}{{ .Firstline }}{{ end }}`, + /**/ `{{ if .Title }}{{ .Title }}{{ end }}`, + /**/ ``, `{{printf "\n"}}`, ), @@ -130,7 +130,7 @@ func templates(api *confluence.API) (*template.Template, error) { `{{ or .Color "Grey" }}`, `{{ or .Title .Color }}`, `{{ or .Subtle false }}`, - ``, + `{{printf "\n"}}`, ), `ac:link:user`: text( @@ -150,7 +150,7 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:jira:ticket`: text( ``, `{{ .Ticket }}`, - ``, + `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/doc/jira-issues-macro-139380.html */ @@ -166,53 +166,53 @@ func templates(api *confluence.API) (*template.Template, error) { `{{ or .Title "Jira Issues" }}`, `{{ .URL }}`, `{{ or .Width "100%" }}`, - ``, + `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/info-tip-note-and-warning-macros-792499127.html */ `ac:box`: text( - `{{printf "\n"}}`, - `{{ or .Icon "false" }}{{printf "\n"}}`, - `{{ if .Title }}{{ .Title }}{{printf "\n"}}{{ end }}`, - `{{ .Body }}{{printf "\n"}}`, + ``, + `{{ or .Icon "false" }}`, + `{{ if .Title }}{{ .Title }}{{ end }}`, + `{{ .Body }}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/table-of-contents-macro-792499210.html */ `ac:toc`: text( - `{{printf "\n"}}`, - `{{ or .Printable "true" }}{{printf "\n"}}`, - `{{ or .Style "disc" }}{{printf "\n"}}`, - `{{ or .MaxLevel "7" }}{{printf "\n"}}`, - `{{ or .Indent "" }}{{printf "\n"}}`, - `{{ or .MinLevel "1" }}{{printf "\n"}}`, - `{{ or .Exclude "" }}{{printf "\n"}}`, - `{{ or .Type "list" }}{{printf "\n"}}`, - `{{ or .Outline "clear" }}{{printf "\n"}}`, - `{{ or .Include "" }}{{printf "\n"}}`, + ``, + `{{ or .Printable "true" }}`, + `{{ or .Style "disc" }}`, + `{{ or .MaxLevel "7" }}`, + `{{ or .Indent "" }}`, + `{{ or .MinLevel "1" }}`, + `{{ or .Exclude "" }}`, + `{{ or .Type "list" }}`, + `{{ or .Outline "clear" }}`, + `{{ or .Include "" }}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/doc/children-display-macro-139501.html */ `ac:children`: text( - `{{printf "\n"}}`, - `{{ if .Reverse}}{{ or .Reverse }}{{printf "\n"}}{{end}}`, - `{{ if .Sort}}{{ .Sort }}{{printf "\n"}}{{end}}`, - `{{ if .Style}}{{ .Style }}{{printf "\n"}}{{end}}`, + ``, + `{{ if .Reverse}}{{ or .Reverse }}{{end}}`, + `{{ if .Sort}}{{ .Sort }}{{end}}`, + `{{ if .Style}}{{ .Style }}{{end}}`, `{{ if .Page}}`, /**/ ``, /**/ ``, /**/ ``, /**/ ``, /**/ ``, - `{{printf "\n"}}{{end}}`, - `{{ if .Excerpt}}{{ .Excerpt }}{{printf "\n"}}{{end}}`, - `{{ if .First}}{{ .First }}{{printf "\n"}}{{end}}`, - `{{ if .Depth}}{{ .Depth }}{{printf "\n"}}{{end}}`, - `{{ if .All}}{{ .All }}{{printf "\n"}}{{end}}`, + `{{end}}`, + `{{ if .Excerpt}}{{ .Excerpt }}{{end}}`, + `{{ if .First}}{{ .First }}{{end}}`, + `{{ if .Depth}}{{ .Depth }}{{end}}`, + `{{ if .All}}{{ .All }}{{end}}`, `{{printf "\n"}}`, ), @@ -236,105 +236,105 @@ func templates(api *confluence.API) (*template.Template, error) { /* https://confluence.atlassian.com/doc/widget-connector-macro-171180449.html#WidgetConnectorMacro-YouTube */ `ac:youtube`: text( - `{{printf "\n"}}`, - `youtube{{printf "\n"}}`, - `com/atlassian/confluence/extra/widgetconnector/templates/youtube.vm{{printf "\n"}}`, - `{{ or .Width "640px" }}{{printf "\n"}}`, - `{{ or .Height "360px" }}{{printf "\n"}}`, - `{{printf "\n"}}`, + ``, + `youtube`, + `com/atlassian/confluence/extra/widgetconnector/templates/youtube.vm`, + `{{ or .Width "640px" }}`, + `{{ or .Height "360px" }}`, + ``, `{{printf "\n"}}`, ), /* https://support.atlassian.com/confluence-cloud/docs/insert-the-iframe-macro/ */ `ac:iframe`: text( - `{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{ if .Frameborder }}{{ .Frameborder }}{{printf "\n"}}{{end}}`, - `{{ if .Scrolling }}{{ .Scrolling }}{{printf "\n"}}{{end}}`, - `{{ if .Align }}{{ .Align }}{{printf "\n"}}{{end}}`, - `{{ or .Width "640px" }}{{printf "\n"}}`, - `{{ or .Height "360px" }}{{printf "\n"}}`, + ``, + ``, + `{{ if .Frameborder }}{{ .Frameborder }}{{end}}`, + `{{ if .Scrolling }}{{ .Scrolling }}{{end}}`, + `{{ if .Align }}{{ .Align }}{{end}}`, + `{{ or .Width "640px" }}`, + `{{ or .Height "360px" }}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/doc/blog-posts-macro-139470.html */ `ac:blog-posts`: text( - `{{printf "\n"}}`, - `{{ if .Content }}{{ .Content }}{{printf "\n"}}{{end}}`, - `{{ if .Spaces }}{{ .Spaces }}{{printf "\n"}}{{end}}`, - `{{ if .Author }}{{ .Author }}{{printf "\n"}}{{end}}`, - `{{ if .Time }}{{ .Time }}{{printf "\n"}}{{end}}`, - `{{ if .Reverse }}{{ .Reverse }}{{printf "\n"}}{{end}}`, - `{{ if .Sort }}{{ .Sort }}{{printf "\n"}}{{end}}`, - `{{ if .Max }}{{ .Max }}{{printf "\n"}}{{end}}`, - `{{ if .Label }}{{ .Label }}{{printf "\n"}}{{end}}`, + ``, + `{{ if .Content }}{{ .Content }}{{end}}`, + `{{ if .Spaces }}{{ .Spaces }}{{end}}`, + `{{ if .Author }}{{ .Author }}{{end}}`, + `{{ if .Time }}{{ .Time }}{{end}}`, + `{{ if .Reverse }}{{ .Reverse }}{{end}}`, + `{{ if .Sort }}{{ .Sort }}{{end}}`, + `{{ if .Max }}{{ .Max }}{{end}}`, + `{{ if .Label }}{{ .Label }}{{end}}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/include-page-macro-792499125.html */ `ac:include`: text( - `{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{printf "\n"}}`, + ``, + ``, + ``, + ``, + ``, + ``, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/excerpt-include-macro-792499101.html */ `ac:excerpt-include`: text( - `{{printf "\n"}}`, - `{{ if .NoPanel }}{{ .NoPanel }}{{ else }}false{{ end }}{{printf "\n"}}`, - `{{ .Page }}{{printf "\n"}}`, + ``, + `{{ if .NoPanel }}{{ .NoPanel }}{{ else }}false{{ end }}`, + `{{ .Page }}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/excerpt-macro-792499102.html */ `ac:excerpt`: text( - `{{printf "\n"}}`, - `{{ if .Hidden }}{{ .Hidden }}{{ else }}false{{ end }}{{printf "\n"}}`, - `{{ if .OutputType }}{{ .OutputType }}{{ else }}BLOCK{{ end }}{{printf "\n"}}`, - `{{printf "\n"}}`, - `{{ .Excerpt }}{{printf "\n"}}`, - `{{printf "\n"}}`, + ``, + `{{ if .Hidden }}{{ .Hidden }}{{ else }}false{{ end }}`, + `{{ if .OutputType }}{{ .OutputType }}{{ else }}BLOCK{{ end }}`, + ``, + `{{ .Excerpt }}`, + ``, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/anchor-macro-792499068.html */ `ac:anchor`: text( - `{{printf "\n"}}`, - `{{ .Anchor }}{{printf "\n"}}`, + ``, + `{{ .Anchor }}`, `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/expand-macro-792499106.html */ `ac:expand`: text( - `{{printf "\n"}}`, - `{{ .Title }}{{printf "\n"}}`, - `{{ .Body }}{{printf "\n"}}`, - ``, + ``, + `{{ .Title }}`, + `{{ .Body }}`, + `{{printf "\n"}}`, ), /* https://confluence.atlassian.com/conf59/user-profile-macro-792499223.html */ `ac:profile`: text( `{{ with .Name | user }}`, - `{{printf "\n"}}`, - `{{printf "\n"}}`, + ``, + ``, `{{ with .AccountID }}`, - /**/ `{{printf "\n"}}`, + /**/ ``, `{{ else }}`, /**/ ``, `{{ end }}`, - `{{printf "\n"}}`, + ``, `{{printf "\n"}}`, `{{ end }}`, ), diff --git a/pkg/mark/testdata/codes.html b/pkg/mark/testdata/codes.html index 163f71c..0757528 100644 --- a/pkg/mark/testdata/codes.html +++ b/pkg/mark/testdata/codes.html @@ -1,88 +1,32 @@

inline

- - -false - - - -bash -false - - - -bash -false - - - -unknown -false - - +false +bashfalse +bashfalse +unknownfalse

text text 2

- -unknown -false - - - -sh -false -A b c - - - -bash -true -A b c - - - -c -true - - - -nested -false -unknownfalse +shfalseA b c +bashtrueA b c +ctrue +nestedfalse - - - -false - - - -true -false - +false +truefalseB; A-->C; B-->D; - C-->D;]]> - - -true -true -my mermaid graph -D;]]> +truetruemy mermaid graphB; A-->C; B-->D; - C-->D;]]> - - -true -false -my mermaid graph -D;]]> +truefalsemy mermaid graphB; A-->C; B-->D; - C-->D;]]> - + C-->D;]]>