Page 1 of 1

support for css counter

PostPosted: Thu Jul 31, 2014 8:50 am
by pengppp11
Hello

I meet a problem and can't not solve it since many days: :cry:

I have XHTML file :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
h1 { counter-reset: section;}
h2 { counter-reset: subsection;}

h2::before {
content: counter(section) ". ";
counter-increment: section;
}
p::before {
content: counter(section) "." counter(subsection) " ";
counter-increment: subsection;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> New Document </title>
</head>

<body>
<h1>HTML</h1>
<h2>HTML hello</h2>
<p>audio</p>
<p>embed</p>
<h2>HTML HAllo</h2>
<p>form</p>
<p>textarea</p>
<p>button</p>
</body>
</html>

And this XHTML can realize automatic numbering in HTML, and now I want convert this file into a DOCX in which can also keep the same style, I used XHTMLImporterImpl but I failed, there is no automatic numbering in the generated DOCX.

Is there any possible way to keep this css and achieve this automatic numbering in DOCX ?

Re: support for css counter

PostPosted: Thu Jul 31, 2014 10:27 am
by jason
Sorry there is no support for counters (http://dev.w3.org/csswg/css-lists/ or otherwise)

Now tracking at https://github.com/plutext/docx4j-ImportXHTML/issues/13 but unless you are minded to contribute an enhancement, this is likely to be treated as rather low priority.

The good news is that xhtmlrenderer does not completely ignore the relevant css ; see for example insertGeneratedContent method at line 1081 of https://github.com/plutext/flyingsaucer ... ilder.java

A possible workaround would be to use the importer's support for converting ol|ul to auto numbered lists (see previous posts).