Page 1 of 1

HTML5 output: duplicated title and h1 tags

Posted: Wed Nov 07, 2018 7:10 pm
by mstockman
Hi, when I run an HTML5 transform on my content, I'm getting the DITA topic title twice in the output: once as a title tag in the resulting HTML topic, and once as an identical H1 tag outside of the head tag.

Is there anyway to suppress this? The title is sufficient in our situation, so the initial h1 is redundant. I've tried this in Oxygen and a pure DITA-OT transform, so it's not specifically an Oxygen question, but it would be nice to be able to control this.

Thanks,
Mike

Re: HTML5 output: duplicated title and h1 tags

Posted: Thu Nov 08, 2018 4:50 pm
by Radu
Hi Mike,

Maybe you can add to the HTML5 transformation your custom CSS stylesheet to set display:none on that <h1> containing the title.
Otherwise if you want that <h1> to be removed from the HTML file you would either need to create a custom HTML customization plugin which tries to override the XSL template producing that <h1> or maybe perform some post-processing (maybe regexp based) on the output folder and remove it.

Regards,
Radu

Re: HTML5 output: duplicated title and h1 tags

Posted: Thu Nov 08, 2018 5:07 pm
by Costin
Hi Mike,

In addition of what Radu already suggested, I just wanted to clarify that the title element from the header of an HTML document does not appear in the content, as it is part of the HTML metadata that is not visible.
It is only used to display the title of the page on a browser tab, or in the title bar of a window, not in the canvas area.

However, if you specifically need to remove the title from the header of the visible HTML content, you could do this easily, hiding it through a CSS:display rule, in your own customization CSS, like Radu also mentioned.

For example, in your custom CSS, you should use something like:

Code: Select all

h1.title {
display: none !important;
}
This should hide the very first header title from each HTML document from your published output.

In the same manner you could hide or style any other elements from your output. All you have to do is use your browser's CSS inspector to identify the specific selector you should use in your CSS, then apply your own properties.
To use a custom CSS, you could pass the .css file into the "args.css" parameter from the "Parameters" tab of the transformation scenario you are using.
Additionally, if in the list of parameters there is also a "args.copycss" parameter, you should set it to "yes".

I hope this helps.

Regards,
Costin

Re: HTML5 output: duplicated title and h1 tags

Posted: Wed Dec 05, 2018 7:13 pm
by mstockman
Thanks, Radu and Costin, for the suggestions. The issue is that we're pulling the HTML content into another system for publishing it to its audience, and that system uses the title to generate a visible heading. So we're getting the heading twice.

I think the solution that Radu mentioned, using a regular expression to delete the h1 content before uploading it to the server, is the solution. It's a little odd that there's no easy way to suppress the h1 from being generated, but it's not the first odd thing about the DITA-OT. :-)

Thanks.

Re: HTML5 output: duplicated title and h1 tags

Posted: Thu Dec 06, 2018 10:15 am
by Radu
Hi,

What you want is not something very usual so there is no parameter to control it.
If you want to do this the proper way, you could create a DITA Open Toolkit plugin which adds a new transformation type based on HTML5. Your new plugin will add an XSLT customization which would override from the base HTML5 plugin the XSLT template which outputs the <h1>.
In the XSLT OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT2.x/plugins/org.dita.html5/xsl/topic.xsl there is an XSLT template:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/topic ')]/*[contains(@class, ' topic/title ')]">
....
which I think is the one responsible for creating those headings. You could override it in your XSLT customization to avoid generating the <h1> for the top level topics.

Regards,
Radu