jelovirt / org.lwdita

LwDITA parser for DITA-OT
http://lwdita.org/
Apache License 2.0
25 stars 19 forks source link

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

Open DunaMariusCosmin opened 2 years ago

DunaMariusCosmin commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 3 months ago

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