Skip to content

Commit

Permalink
Children display macro (#133)
Browse files Browse the repository at this point in the history
Added Children Display macro
  • Loading branch information
jevfok authored Nov 8, 2021
1 parent cc98590 commit f3ba7c5
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ By default, mark provides several built-in templates and macros:

See: https://confluence.atlassian.com/doc/widget-connector-macro-171180449.html#WidgetConnectorMacro-YouTube

* template: `ac:children` to include Children Display macro
- Reverse (Reverse Sort): Use with the `Sort Children By` parameter. When set, the sort order changes from ascending to descending.
- `true`
- `false` (Default)
- Sort (Sort Children By):
- `creation` — to sort by content creation date
- `title` — to sort alphabetically on title
- `modified` — to sort of last modification date.
- If not specified, manual sorting is used if manually ordered, otherwise alphabetical.
- Style (Heading Style): Choose the style used to display descendants.
- from `h1` to `h6`
- If not specified, default style is applied.
- Page (Parent Page):
- `/` — to list the top-level pages of the current space, i.e. those without parents.
- `pagename` — to list the children of the specified page.
- `spacekey:pagename` — to list the children of the specified page in the specified space.
- If not specified, the current page is used.
- Excerpt (Include Excerpts): Allows you to include a short excerpt under each page in the list.
- `none` - no excerpt will be displayed. (Default)
- `simple` - displays the first line of text contained in an Excerpt macro any of the returned pages. If there is not an Excerpt macro on the page, nothing will be shown.
- `rich content` - displays the contents of an Excerpt macro, or if there is not an Excerpt macro on the page, the first part of the page content, including formatted text, images and some macros.
- First (Number of Children): Restrict the number of child pages that are displayed at the top level.
- If not specified, no limit is applied.
- Depth (Depth of Descendants): Enter a number to specify the depth of descendants to display. For example, if the value is 2, the macro will display 2 levels of child pages. This setting has no effect if `Show Descendants` is enabled.
- If not specified, no limit is applied.
- All (Show Descendants): Choose whether to display all the parent page's descendants.
- `true`
- `false` (Default)

See: https://confluence.atlassian.com/doc/children-display-macro-139501.html

* macro `@{...}` to mention user by name specified in the braces.

## Template & Macros Usecases
Expand Down Expand Up @@ -297,7 +328,38 @@ value, so feel free to include only the ones that you require.


[Confluence TOC Macro]:https://confluence.atlassian.com/conf59/table-of-contents-macro-792499210.html
### Insert Children Display

To include Children Display (TOC displaying children pages) use following macro:

```markdown
<!-- Macro: :children:
Template: ac:children
-->

# This is my nicer title

:children:
```

You can use various [parameters](https://confluence.atlassian.com/conf59/children-display-macro-792499081.html) to modify Children Display:

```markdown
<!-- Macro: :children:
Template: ac:children
Sort: title
Style: h3
Excerpt: simple
First: 10
Page: Space:Page title
Depth: 2
Reverse: false
All: false -->

# This is my nicest title

:children:
```
### Insert Jira Ticket

**article.md**
Expand Down Expand Up @@ -487,4 +549,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
21 changes: 21 additions & 0 deletions pkg/mark/stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,27 @@ func templates(api *confluence.API) (*template.Template, error) {
`</ac:structured-macro>{{printf "\n"}}`,
),

/* https://confluence.atlassian.com/doc/children-display-macro-139501.html */

`ac:children`: text(
`<ac:structured-macro ac:name="children">{{printf "\n"}}`,
`{{ if .Reverse}}<ac:parameter ac:name="reverse">{{ or .Reverse }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .Sort}}<ac:parameter ac:name="sort">{{ .Sort }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .Style}}<ac:parameter ac:name="style">{{ .Style }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .Page}}`,
/**/ `<ac:parameter ac:name="page">`,
/**/ `<ac:link>`,
/**/ `<ri:page ri:content-title="{{ .Page}}"/>`,
/**/ `</ac:link>`,
/**/ `</ac:parameter>`,
`{{printf "\n"}}{{end}}`,
`{{ if .Excerpt}}<ac:parameter ac:name="excerptType">{{ .Excerpt }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .First}}<ac:parameter ac:name="first">{{ .First }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .Depth}}<ac:parameter ac:name="depth">{{ .Depth }}</ac:parameter>{{printf "\n"}}{{end}}`,
`{{ if .All}}<ac:parameter ac:name="all">{{ .All }}</ac:parameter>{{printf "\n"}}{{end}}`,
`</ac:structured-macro>{{printf "\n"}}`,
),

/* https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html */

`ac:emoticon`: text(
Expand Down

0 comments on commit f3ba7c5

Please sign in to comment.