kovetskiy / mark

Sync your markdown files with Confluence pages.
https://samizdat.dev
Apache License 2.0
993 stars 148 forks source link

`drop-h1` has no effect, end up with double titles #298

Closed AX-LLaidley closed 1 year ago

AX-LLaidley commented 1 year ago

What happened? When I include the drop-h1 or --h1_drop don't actually cause the initial H1 heading in the markdown doc to be dropped. This results in the H1 being used as the page title in Confluence (as it should be when --title-from-h1 or --h1_title are used), and the H1 heading showing up at the beginning of the page text, where it shouldn't be, because the title is also present in the frontmatter. The only way I've found around this is to remove the H1 from the document entirely and rely on the title in the frontmatter.

What did you expect to happen? I expected the H1 to be used to title the page in Confluence, and not to show up in the page text, as it should be dropped.

How can we reproduce the behavior you experienced? Steps to reproduce the behavior:

  1. Take an example Markdown file that contains the frontmatter for Mark and includes both the title parameter in the frontmatter and a H1 heading below the frontmatter, at the beginning of the doc.
  2. Push the file to Confluence using `mark --debug --trace --title-from-h1 --drop-h1 -c ~/.config/mark -u -p -b -f "docs/Knowledge-Base/Getting-Started/Automox-University.md"
  3. Then, check the Confluence page that was just created. You will see it has 2 titles.

In case this is related to specific markdown, please provide a minimal markdown example here.

<!-- Space: TDT -->
<!-- Parent: Mark Test 2 -->
<!-- Title: Automox University -->
<!-- Layout: article -->
<!-- Type: page -->
<!-- Include: ../../disclaimer.md -->
<!-- Attachment: ../../../static/images/Automox-University/ax_uni.png -->
<!-- Macro: :box:([^:]+):([^:]*):(.+):
     Template: ac:box
     Icon: true
     Name: ${1}
     Title: ${2}
     Body: ${3} -->
<!-- Macro: :toc:
     Template: ac:toc
     Printable: 'false'
     MinLevel: 2 -->

# Automox University

Information (please complete the following information):

Logs or other output image

Additional context Add any other context about the problem here.

mrueg commented 1 year ago

Is there a specific need to specify title via and then use --title-from-h1 at the same time? I would assume since you might be running it on several files, should have priority over the h1 generated one as there might be some without title. The --drop-h1 should happen probably on both still.

@kovetskiy any thoughts?

joyfulrabbit commented 1 year ago

You can see clearly there is a typo in the readme.md sample configuration. I worked around this a while ago by looking at the source code, but the inaccurate documentation on the page and lackluster examples really put me off initially, much as is happening with the poster above.

When I use the example configuration given in readme.md :

h1-title = true
h1-drop = true

I get:

2023-05-10 14:49:52.036 DEBUG              drop-h1: false
2023-05-10 14:49:52.036 DEBUG        title-from-h1: false

and an error: 2023-05-10 14:49:52.036 FATAL page title is not set ('Title' header is not set and '--title-from-h1' option and 'h1_title' config is not set or there is no H1 in the file)

If I look in the source code for the correct syntax: h1_title = true h1_drop = true

2023-05-10 14:45:55.682 DEBUG              drop-h1: true
2023-05-10 14:45:55.682 DEBUG        title-from-h1: true

It works fine. The documentation is just wrong.

joyfulrabbit commented 1 year ago

https://github.com/kovetskiy/mark/pull/315

mrueg commented 1 year ago

No response from reporter, closing. Please feel free to reopen if the issue still exists.