Allow Title via h1 without any other metadata (#229)

This commit is contained in:
Manuel Rüger 2023-01-03 18:52:48 +01:00 committed by GitHub
parent ef71aa1792
commit 55b58bd59b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -503,10 +503,10 @@ mark -h | --help
- `-c <path>` or `--config <path>` — Specify a path to the configuration file. - `-c <path>` or `--config <path>` — Specify a path to the configuration file.
- `-k` — Lock page editing to current user only to prevent accidental - `-k` — Lock page editing to current user only to prevent accidental
manual edits over Confluence Web UI. manual edits over Confluence Web UI.
- `--space <space>` - Use specified space key. If not specified space ley must be set in a page metadata. - `--space <space>` - Use specified space key. If the space key is not specified, it must be set in the page metadata.
- `--drop-h1` Don't include H1 headings in Confluence output. - `--drop-h1` Don't include H1 headings in Confluence output.
This option corresponds to the `h1_drop` setting in the configuration file. This option corresponds to the `h1_drop` setting in the configuration file.
- `--title-from-h1` - Extract page title from a leading H1 heading. If no H1 heading on a page then title must be set in a page metadata. - `--title-from-h1` - Extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata.
This option corresponds to the `h1_title` setting in the configuration file. This option corresponds to the `h1_title` setting in the configuration file.
- `--dry-run` — Show resulting HTML and don't update Confluence page content. - `--dry-run` — Show resulting HTML and don't update Confluence page content.
- `--minor-edit` — Don't send notifications while updating Confluence page. - `--minor-edit` — Don't send notifications while updating Confluence page.

21
main.go
View File

@ -66,11 +66,11 @@ Options:
Supports file globbing patterns (needs to be quoted). Supports file globbing patterns (needs to be quoted).
-k Lock page editing to current user only to prevent accidental -k Lock page editing to current user only to prevent accidental
manual edits over Confluence Web UI. manual edits over Confluence Web UI.
--space <space> Use specified space key. If not specified space ley must --space <space> Use specified space key. If the space key is not specified, it must
be set in a page metadata. be set in the page metadata.
--drop-h1 Don't include H1 headings in Confluence output. --drop-h1 Don't include H1 headings in Confluence output.
--title-from-h1 Extract page title from a leading H1 heading. If no H1 heading --title-from-h1 Extract page title from a leading H1 heading. If no H1 heading
on a page then title must be set in a page metadata. on a page exists, then title must be set in the page metadata.
--dry-run Resolve page and ancestry, show resulting HTML and exit. --dry-run Resolve page and ancestry, show resulting HTML and exit.
--compile-only Show resulting HTML and don't update Confluence page content. --compile-only Show resulting HTML and don't update Confluence page content.
--minor-edit Don't send notifications while updating Confluence page. --minor-edit Don't send notifications while updating Confluence page.
@ -197,11 +197,16 @@ func processFile(
} }
if pageID == "" && meta == nil { if pageID == "" && meta == nil {
log.Fatal( if flags.TitleFromH1 && flags.Space != "" {
`specified file doesn't contain metadata ` + meta = &mark.Meta{}
`and URL is not specified via command line ` + meta.Type = "page"
`or doesn't contain pageId GET-parameter`, } else {
) log.Fatal(
`specified file doesn't contain metadata ` +
`and URL is not specified via command line ` +
`or doesn't contain pageId GET-parameter`,
)
}
} }
switch { switch {