Forum Bugs

code indentation from geishi code formatter not ok

hamishwillee
The code below correctly indents the position of brackets in HTML, however the printed version (with no CSS) left-indents the brackets {

<html><head><title>Temp</title></head><body><h1 class="titleheading">Temp</h1><p>Test code. Note that below block is properly indented
</p>
<pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> AppendEntryL<span style="color: #008000;">&#40;</span> node_array<span style="color: #000040;">&amp;</span> myArray, node<span style="color: #000040;">&amp;</span> element <span style="color: #008000;">&#41;</span><br /><span style="color: #008000;">&#123;</span><br />   <span style="color: #0000ff;">try</span> <span style="color: #008000;">&#123;</span><br />      myArray.<span style="color: #007788;">append</span><span style="color: #008000;">&#40;</span> element <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span><br />      <span style="color: #008000;">&#125;</span><br />   <span style="color: #0000ff;">catch</span> <span style="color: #008000;">&#40;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">bad_alloc</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />      User<span style="color: #008080;">::</span><span style="color: #007788;">Leave</span><span style="color: #008000;">&#40;</span> KErrNoMemory <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span><br />      <span style="color: #008000;">&#125;</span><br /><span style="color: #008000;">&#125;</span></pre>
<p><br />
</p> </body></html>


I don't know why this would cause problems, but I can see that if I
have text following the line break and before a span then the
indentation is obeyed:
<br />      User<span style="color:

However if there is no text then the spaces (for example before try) are ignored
<br />    <span style="color: #0000ff;">try</span>


Thoughts/workarounds?
mikeday
This appears to be a problem with the libxml2 HTML parser that we are using in Prince. Unfortunately the whitespace between elements is being thrown away in some situations when it should not be. As this happens before Prince processes the document, it is difficult for us to workaround in the short term, and we will need to fix the parser.

There are some possible workarounds. The XML parser never throws away whitespace in any circumstances, and will handles this case correctly. However, it does require your input document to be well-formed XML. Another option is to wrap up the space in a <span> of its own, which will be correctly preserved.
hamishwillee
Thank you very much. The input we get from wiki is HTML, and falls over with prince (entities not defined, mismatched tags etc). Unless we use a different exporter we're stuck with that. I guess I could add spans everywhere, but it seems a bit silly.

Any sort of timeframe for an update?
mikeday
We've found a workaround for the problem, and will be able to include a fix in Prince 7.1.
hamishwillee
mikeday wrote:
We've found a workaround for the problem, and will be able to include a fix in Prince 7.1.

That's fantastic. Any particular timeline for the release of v7.1 (ie next month, next quarter?)
mikeday
We may make an interim release available for most platforms before the end of the year, if all goes well.
hamishwillee
mikeday wrote:
We may make an interim release available for most platforms before the end of the year, if all goes well.


Hi Mike
Did an interim release appear? The downloads page appears to be 7.0 so it appears not. Any further timeframes?

Regards
Hamish
mikeday
In fact the updated packages for Prince 7.1 have been prepared, and are just waiting for the release notes and announcement on the website. You can download them now by changing the "7.0" in the download URL to "7.1". :D
mikeday
...and that took a lot longer than we expected, but the official release of Prince 7.1 is now available! :D