Merge pull request #250 from Fethbita/master

ac:image macro
This commit is contained in:
Manuel Rüger
2023-02-13 15:50:17 +01:00
committed by GitHub
2 changed files with 26 additions and 0 deletions

View File

@@ -512,6 +512,22 @@ This is a [link to an existing confluence page](ac:Pagetitle)
And this is how to link when the linktext is the same as the [Pagetitle](ac:)
```
### Add width for an image
Use the following macro:
```markdown
<!-- Macro: \!\[.*\]\((.+)\)\<\!\-\- width=(.*) \-\-\>
Template: ac:image
Attachment: ${1}
Width: ${2} -->
```
And attach any image with the following
```markdown
![Example](../images/example.png)<!-- width=300 -->
```
The width will be the commented html after the image (in this case 300px).
## Installation
### Homebrew

View File

@@ -84,6 +84,13 @@ func templates(api *confluence.API) (*template.Template, error) {
"]]><![CDATA[]]]]><![CDATA[>",
)
},
"convertAttachment": func(data string) string {
return strings.ReplaceAll(
data,
"/",
"_",
)
},
},
)
@@ -210,6 +217,9 @@ func templates(api *confluence.API) (*template.Template, error) {
`ac:emoticon`: text(
`<ac:emoticon ac:name="{{ .Name }}"/>`,
),
`ac:image`: text(
`<ac:image {{ if .Width}}ac:width="{{ .Width }}"{{end}}><ri:attachment ri:filename="{{ .Attachment | convertAttachment }}"/></ac:image>`,
),
/* https://confluence.atlassian.com/doc/widget-connector-macro-171180449.html#WidgetConnectorMacro-YouTube */