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

The HTML headings from markdown document are converted in DITA title elements #92

Open
DunaMariusCosmin opened this issue Mar 10, 2022 · 3 comments

Comments

@DunaMariusCosmin
Copy link
Contributor

DunaMariusCosmin commented Mar 10, 2022

I have the following makdown document:

# Title

<h1 id="newTitle">New Title</h1>

Content

The HTML <h1> element is converted into a DITA <title> element and the resulted document is invalid.
I think it should be handled like markdown headings and a new topic should be created when it's converted to DITA.

@jelovirt
Copy link
Owner

jelovirt commented Aug 6, 2022

So the suggestion is that

# Title

<h1 id="newTitle">New Title</h1>

Content

is treated as

# Title

# New Title {#newTitle}

Content

and would be converted to

<dita>
  <topic id="title">
    <title>Title</title>
  </topic>
  <topic id="newTitle">
    <title>New Title</title>
    <body>Content</body>
  </topic>
</dita>

It's a good fallback, but might cause confusion.

@jelovirt
Copy link
Owner

jelovirt commented Nov 5, 2022

The implementation would need to first convert HTML headers into AST, because counting header jumps and whether <dita> wrapper is needed is done by reading the AST.

@michael-nok
Copy link

michael-nok commented Jun 25, 2024

I wouldn't recommend supporting this. Markdown doesn't like multiple H1 headers in a single file (re: MD025)

If you want to separate your topic and your first header, consider using a YAML title instead.
https://github.com/jelovirt/org.lwdita/wiki/Common-syntax#metadata

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

No branches or pull requests

3 participants