import_html fails to set the page title for HTML produced through SGML as a single page.
It does not fail to set the page title for HTML produced through SGML as multiple pages.

I am attaching an example testcase of a manual written in SGML, including the HTML output as a single page and as multiple pages. Attempting to import the single page HTML version of the manual demonstrates the bug.

To rebuild the manual from SGML, run:
$ make clean
$ make

Comments

dman’s picture

Incredibly thorough test case - thankyou, it all becomes clear.
SGML is a great target to work with import_html, so I'm pleased to see it.

What I'm seeing here is:
An all-in-one (single) page is a document made up of many chapters.
When such a document is imported using "default" template, the chapter headings within the body text go missing.

What's happening is simple.

In the usual case, an HTML doc has a single <h1> buried somewhere in the HTML - usually in the same place as the text. import_html scans the document for that tag, and if found, uses it for the document title but also removes it from the flow of text where it was found. This is usually helpful as it prevents having the title repeated in the body content area where it would be messy.

The sample single output document you supplied had several different H1 tags in the same doc.
Semantically, that is unexpected. More that one top-level title for a single doc won't import into Drupal or much else.
Practically, the system found the title it wanted, then deleted the titles it didn't.

Anyway, All you need to do is trim out the bit that tidies up the document and removes h1s

Edit the xsl template you've chosen (or a copy of it) html2simplehtml.csl by default.
Remove the following block

  <xsl:template match="*[local-name()='h1']|*[@id='pagetitle']">
  <!-- remove these from the flow altogether if they were in the content -->
  </xsl:template>

This will - in all cases, even the first one - leave the H1 where it was in the body. Your doc will show the title as a "title" and also as an H1 in the body text - which is what you need if using a numbering system as your example shows.

There may be an extra bit of logic that can remove only the first H1 found, but that's enough for now.

There may be an option in the docbook converter to start numbering of subchapters from H2 - leaving H1 for the document or book title. That would be good (and, IMO semantically more correct)

mkmk’s picture

Thanks a lot for your prompt response and the suggested correction.

It worked. I can see the Chapter titles now.

As you mentioned, one side-effect is that output for multiple pages now shows the chapter title twice: once as the page title, and once in the text. But if I had to pick between the two evils, I'd rather have it shown for both single pages and multiple pages, rather than missing for single pages.

I haven't looked into the docbook converted at all. This support you provided, for SGML documents, is very important in my opinion.

Thanks again.

dman’s picture

Status: Active » Fixed

Seems to be the answer

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mkmk’s picture

Will this change be pushed in the module code permanently ?

dman’s picture

No, as having multiple H1 tags in the input text is much less common than having a single H1 in the text.
Removing a single instance from the text flow (and putting it as the title) is the best-expected-case.

There may be a case for counting the number of H1s and making a guess about what to do, but it's a fringe case. (and I'm not sure how to )
The provided html2simplehtml is just a best-case starting point. Almost all real import jobs will require you to copy it and tweak it a bit. So use your own modifications and your own XSL

In the usual case, an HTML doc has a single <h1> buried somewhere in the HTML - usually in the same place as the text. import_html scans the document for that tag, and if found, uses it for the document title but also removes it from the flow of text where it was found. This is usually helpful as it prevents having the title repeated in the body content area where it would be messy.

The sample single output document you supplied had several different H1 tags in the same doc.
Semantically, that is unexpected. More that one top-level title for a single doc won't import into Drupal or much else.
Practically, the system found the title it wanted, then deleted the titles it didn't.