mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
Feature/h1 title (#196)
* h1_title config * introduce h1_title in config * add h1_drop config setting * allsow allow h1_drop in config
This commit is contained in:
parent
3c7bd6133f
commit
4c812741ac
@ -440,7 +440,9 @@ mark -h | --help
|
|||||||
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 not specified space ley must be set in a 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.
|
||||||
- `--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 then title must be set in a page metadata.
|
||||||
|
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.
|
||||||
- `--trace` — Enable trace logs.
|
- `--trace` — Enable trace logs.
|
||||||
@ -455,6 +457,8 @@ username = "your-email"
|
|||||||
password = "password-or-api-key-for-confluence-cloud"
|
password = "password-or-api-key-for-confluence-cloud"
|
||||||
# If you are using Confluence Cloud add the /wiki suffix to base_url
|
# If you are using Confluence Cloud add the /wiki suffix to base_url
|
||||||
base_url = "http://confluence.local"
|
base_url = "http://confluence.local"
|
||||||
|
h1_title = true
|
||||||
|
h1_drop = true
|
||||||
```
|
```
|
||||||
|
|
||||||
**NOTE**: Labels aren't supported when using `minor-edit`!
|
**NOTE**: Labels aren't supported when using `minor-edit`!
|
||||||
@ -569,6 +573,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center"><a href="http://www.devin.com.br/"><img src="https://avatars.githubusercontent.com/u/349457?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hugo Cisneiros</b></sub></a><br /><a href="https://github.com/kovetskiy/mark/commits?author=eitchugo" title="Code">💻</a></td>
|
<td align="center"><a href="http://www.devin.com.br/"><img src="https://avatars.githubusercontent.com/u/349457?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hugo Cisneiros</b></sub></a><br /><a href="https://github.com/kovetskiy/mark/commits?author=eitchugo" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://github.com/jevfok"><img src="https://avatars.githubusercontent.com/u/54530686?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jevfok</b></sub></a><br /><a href="https://github.com/kovetskiy/mark/commits?author=jevfok" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/jevfok"><img src="https://avatars.githubusercontent.com/u/54530686?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jevfok</b></sub></a><br /><a href="https://github.com/kovetskiy/mark/commits?author=jevfok" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="https://dev.to/mmiranda"><img src="https://avatars.githubusercontent.com/u/16670310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mateus Miranda</b></sub></a><br /><a href="#maintenance-mmiranda" title="Maintenance">🚧</a></td>
|
<td align="center"><a href="https://dev.to/mmiranda"><img src="https://avatars.githubusercontent.com/u/16670310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mateus Miranda</b></sub></a><br /><a href="#maintenance-mmiranda" title="Maintenance">🚧</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/Skeeve"><img src="https://avatars.githubusercontent.com/u/725404?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Skeeve</b></sub></a><br /><a href="https://github.com/kovetskiy/mark/commits?author=Skeeve" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ type Config struct {
|
|||||||
Username string `env:"MARK_USERNAME" toml:"username"`
|
Username string `env:"MARK_USERNAME" toml:"username"`
|
||||||
Password string `env:"MARK_PASSWORD" toml:"password"`
|
Password string `env:"MARK_PASSWORD" toml:"password"`
|
||||||
BaseURL string `env:"MARK_BASE_URL" toml:"base_url"`
|
BaseURL string `env:"MARK_BASE_URL" toml:"base_url"`
|
||||||
|
H1Title bool `env:"MARK_H1_TITLE" toml:"h1_title"`
|
||||||
|
H1Drop bool `env:"MARK_H1_DROP" toml:"h1_drop"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(path string) (*Config, error) {
|
func LoadConfig(path string) (*Config, error) {
|
||||||
|
19
main.go
19
main.go
@ -120,6 +120,14 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ! flags.TitleFromH1 && config.H1Title {
|
||||||
|
flags.TitleFromH1 = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! flags.DropH1 && config.H1Drop {
|
||||||
|
flags.DropH1 = true
|
||||||
|
}
|
||||||
|
|
||||||
creds, err := GetCredentials(flags, config)
|
creds, err := GetCredentials(flags, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -212,7 +220,7 @@ func processFile(
|
|||||||
if meta.Title == "" {
|
if meta.Title == "" {
|
||||||
log.Fatal(
|
log.Fatal(
|
||||||
`page title is not set ('Title' header is not set ` +
|
`page title is not set ('Title' header is not set ` +
|
||||||
`and '--title-from-h1' option is not set or there is no H1 in the file)`,
|
`and '--title-from-h1' option and 'h1_title' config is not set or there is no H1 in the file)`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +283,14 @@ func processFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if flags.CompileOnly {
|
if flags.CompileOnly {
|
||||||
fmt.Println(mark.CompileMarkdown(markdown, stdlib))
|
if flags.DropH1 {
|
||||||
|
log.Info(
|
||||||
|
"the leading H1 heading will be excluded from the Confluence output",
|
||||||
|
)
|
||||||
|
markdown = mark.DropDocumentLeadingH1(markdown)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(mark.CompileMarkdown(markdown, stdlib))
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user