From deb7cd9cbc36e8784b6df2c5112e2c7eea21196c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 31 Mar 2023 17:25:33 +0200 Subject: [PATCH] feat: Add Excerpt and ExcerptInclude macros --- README.md | 9 +++++++++ pkg/mark/stdlib/stdlib.go | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/README.md b/README.md index 3ce0f18..d643044 100644 --- a/README.md +++ b/README.md @@ -375,6 +375,15 @@ By default, mark provides several built-in templates and macros: - Page: the page to be included - Space: the space the page is in (optional, otherwise same space) +* template: `ac:excerpt-include` to include the excerpt from another page + - Page: the page the excerpt should be included from + - NoPanel: Determines whether Confluence will display a panel around the excerpted content (optional, default: false) + +* template: `ac:excerpt` to create an excerpt and include it in the page + - Excerpt: The text you want to include + - OutputType: Determines whether the content of the Excerpt macro body is displayed on a new line or inline (optional, options: "BLOCK" or "INLINE", default: BLOCK) + - Hidden: Hide the excerpt content (optional, default: false) + * macro `@{...}` to mention user by name specified in the braces. ## Template & Macros Usecases diff --git a/pkg/mark/stdlib/stdlib.go b/pkg/mark/stdlib/stdlib.go index 62daf5f..d8b1998 100644 --- a/pkg/mark/stdlib/stdlib.go +++ b/pkg/mark/stdlib/stdlib.go @@ -273,6 +273,27 @@ func templates(api *confluence.API) (*template.Template, error) { `{{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"}}`, + `{{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"}}`, + `{{printf "\n"}}`, + ), + // TODO(seletskiy): more templates here } { templates, err = templates.New(name).Parse(body)