Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong title when using --title-from-h1 and inline template macros #414

Open
cabidop opened this issue Jan 25, 2024 · 2 comments
Open

Wrong title when using --title-from-h1 and inline template macros #414

cabidop opened this issue Jan 25, 2024 · 2 comments
Labels

Comments

@cabidop
Copy link

cabidop commented Jan 25, 2024

What happened?

When trying to use inline template macros with the --title-from-h1 parameter, instead of using the leading H1 header for the Confluence page title mark is using the template name of the first macro minus its first character (i.e. if the first inline template is defined as Template: #my_template the Confluence title becomes y_template).

What did you expect to happen?

The Confluence title matches the actual leading H1 header.

How can we reproduce the behavior you experienced?

  1. Enable the --title-from-h1 parameter.
  2. Create a document with no <!-- Title --> header and at least one <!-- Macro --> header with an inline template defined.
  3. Try to sync the document with Confluence.

Minimal markdown example where the Confluence title becomes nline instead of Some title:

<!-- Space: Test -->
<!-- Parent: Test -->
<!-- Macro: <test />
        Template: #inline
        inline: Some test
    -->

# Some title

<test />

Information (please complete the following information)

  • Mark Version (mark --version): v9.11.1
  • Mark Parameters: --title-from-h1
  • Confluence Hosting: Cloud
  • Confluence Version: -
  • Environment specific Information: running in Github Actions

Logs or other output

No relevant logs that might highlight or help debugging the issue.

Additional context

Looks like the regex used in the ExtractDocumentLeadingH1 function might be the culprit, as it does match the observed behaviour.

@cabidop cabidop added the bug label Jan 25, 2024
@mrueg
Copy link
Collaborator

mrueg commented Jan 25, 2024

Good point, the extraction logic should probably be part of the custom parser and not be done via a regular expression.

@cabidop
Copy link
Author

cabidop commented Jan 31, 2024

Hey @mrueg, not fully sure of what the solution you proposed implies (moving the extraction to the custom parser) but a quick fix could be to just update the regex to better fit the Markdown specification for headings. Something like this should do the job (I can open a PR to add the change together with some tests): ^\s{0,3}#\s+(.*)(\s+#+)?\s*\n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants