Skip to content

Commit

Permalink
feat: Add Excerpt and ExcerptInclude macros
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Mar 31, 2023
1 parent 1285947 commit deb7cd9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions pkg/mark/stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,27 @@ func templates(api *confluence.API) (*template.Template, error) {
`</ac:structured-macro>{{printf "\n"}}`,
),

/* https://confluence.atlassian.com/conf59/excerpt-include-macro-792499101.html */

`ac:excerpt-include`: text(
`<ac:macro ac:name="excerpt-include">{{printf "\n"}}`,
`<ac:parameter ac:name="nopanel">{{ if .NoPanel }}{{ .NoPanel }}{{ else }}false{{ end }}</ac:parameter>{{printf "\n"}}`,
`<ac:default-parameter>{{ .Page }}</ac:default-parameter>{{printf "\n"}}`,
`</ac:macro>{{printf "\n"}}`,
),

/* https://confluence.atlassian.com/conf59/excerpt-macro-792499102.html */

`ac:excerpt`: text(
`<ac:structured-macro ac:name="excerpt">{{printf "\n"}}`,
`<ac:parameter ac:name="hidden">{{ if .Hidden }}{{ .Hidden }}{{ else }}false{{ end }}</ac:parameter>{{printf "\n"}}`,
`<ac:parameter ac:name="atlassian-macro-output-type">{{ if .OutputType }}{{ .OutputType }}{{ else }}BLOCK{{ end }}</ac:parameter>{{printf "\n"}}`,
`<ac:rich-text-body>{{printf "\n"}}`,
`{{ .Excerpt }}{{printf "\n"}}`,
`</ac:rich-text-body>{{printf "\n"}}`,
`</ac:structured-macro>{{printf "\n"}}`,
),

// TODO(seletskiy): more templates here
} {
templates, err = templates.New(name).Parse(body)
Expand Down

0 comments on commit deb7cd9

Please sign in to comment.