DITA to Markdown transformation

Post here questions and problems related to editing and publishing DITA content.
luodan
Posts: 19
Joined: Wed Aug 24, 2022 7:20 am

DITA to Markdown transformation

Post by luodan »

Hi there,
We want to use DITA to edit docs and publish it into markdown format, is there a way to customize the formatting of the output?
For example, the following picture shows the expected formatting:
image.png
However, I couldn't manage to define the title level in DITA files, and there is also an indent issue in the output md file:
image.png
image.png
Hope to get your support soon, thanks :)
You do not have the required permissions to view the files attached to this post.
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA to Markdown transformation

Post by Radu »

Hi,
Oxygen's DITA to Markdown publishing is done using this third party open source plugin:
https://github.com/jelovirt/org.lwdita
The plugin is installed in the "OXYGEN-INSTALL-DIR/frameworks/dita/DITA-OT3.x" folder and to my knowledge uses XSLT to produce Markdown from DITA XML (OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.lwdita/xsl)
So it's probably possible to make some changes to the XSLTs...
About your initial questions:
However, I couldn't manage to define the title level in DITA files
With DITA XML you can nest topics inside each other, so from something like this:

Code: Select all

<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="introduction" translate="no">
  <title>Topic</title>
  <topic id="topic_uwh_l41_5xb">
    <title>Topic2</title>
    <topic id="topic_ny4_l41_5xb">
      <title>Topic3</title>
    </topic>
  </topic>
</topic>
the produced Markdown content should look like this:

Code: Select all

# Topic {#introduction}

## Topic2 {#topic_uwh_l41_5xb}

### Topic3 {#topic_ny4_l41_5xb}
and there is also an indent issue in the output md file
How exactly does the DITA XML content look like for those two lists? If you were to write directly those lists in Markdown how would you do that? From what I know plain Markdown cannot be used to represent list items or table cells containing multiple block level elements.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
luodan
Posts: 19
Joined: Wed Aug 24, 2022 7:20 am

Re: DITA to Markdown transformation

Post by luodan »

Hi Radu,
Thanks for pointing out that I could nest topics within each other. Also, I used the embedded scenario transformation module and successfully generated a markdown file.
About the weird indent problem, it turns out that it's a bug of the oxy-placeholder tag, if I use this tag just for placeholder, the Dita file and output file look like this:
image.png
image.png
But when I pass in characters inside the tags, the output file seems just like I expected:
image.png
You do not have the required permissions to view the files attached to this post.
luodan
Posts: 19
Joined: Wed Aug 24, 2022 7:20 am

Re: DITA to Markdown transformation

Post by luodan »

Here comes another one:
I put a <b></b> tag around a word in the template, like this:
image.png
But when I create a topic based on that template, the b tag is gone, like this:
image.png
I tried to put a ph tag outside the b tag, but it didn't work :|
You do not have the required permissions to view the files attached to this post.
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA to Markdown transformation

Post by Radu »

Hi,
The "oxy-placeholder" processing instruction is used as a place holder in a new file template, usually people create a DITA topic based on the new file template, fill the place holder values and then they publish. So I do not see a usecase why someone would publish a DITA topic containing those place holders, and thus I'm not sure if this is worth investigating further.

About this other remark:
I put a <b></b> tag around a word in the template...
So you create a new file template for your framework, then use Oxygen's main menu File->"New" wizard dialog to create a DITA topic based on that template? And the created DITA topic does not have a <b> bold element inside it although it was in the file template? In my opinion you may be using to create the topic a different new file template as this should work, Oxygen does not randomly remove content from a new file template file when using it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
luodan
Posts: 19
Joined: Wed Aug 24, 2022 7:20 am

Re: DITA to Markdown transformation

Post by luodan »

Yes it's another placeholder issue, when I input actual content to replace the placeholder, it's fine.
Thanks for your help :D
laurenkusa
Posts: 2
Joined: Fri Feb 10, 2017 6:00 am

Re: DITA to Markdown transformation

Post by laurenkusa »

Hi Radu,
for transformation to Markdown from DITA, is https://github.com/jelovirt/org.lwdita still the way to go? Can i run this from Oxygen following hte steps for installing a plugin?
Thanks,
Lauren
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA to Markdown transformation

Post by Radu »

Hi Laurent,
This particular plugin is indeed the one which is used when publishing DITA to markdown. The plugin comes pre-bundled with the DITA OT which we ship inside the Oxygen installation (you can look in the "OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT" for this plugin).
So you can just run DITA to Markdown transformations from the Oxygen DITA Maps Manager view ->'Configure Transformation Scenarios' dialog.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply