Convert html notes before printing

Lubomir I. Ivanov neolit123 at gmail.com
Tue Oct 27 05:31:33 PDT 2015


On 27 October 2015 at 13:19, Robert Helling <helling at lmu.de> wrote:
> Hi,
>
> I noticed that when printing a planned dive the notes are html glibberish.
> So here is a patch that converts html to plain text before printing.
>
>
>
> Since I am still unable to build a working print system here on my mac, this
> is untested. So please test before applying.
>
> There might be a better way to render html for printing rather than
> QTextDocument toPlainText(). But I don’t know enough about this template
> thing to implement it right now. I tried turning m_notes into a
> QTextDocument that then would have a print() method but could’t get it to
> compile
>

hey Robert,

one small issue with the patch:

+ if (strcmp(dive->dc.model, "planned dive")) {
^ it should be !strcmp(...) to enter that branch and convert the HTML to PT.

other than that ACK.

yes, QTextDocument is fine because i don't have any good solutions here...
any formatting pretty much in the notes is going to be destroyed by
the Grantlee variable replacement.

it does the following inside the template:
<p> {{ dive.notes}} </p>
and this is not parsed at all, as it's placed *after* the HTML is
parsed and any HTML tags are going to placed in as if CDATA is used on
them.

so, if even if you have your nice \n line breaks and lists in the
notes as plain text, all that is going to be lost when the plain text
is placed in the <p> tag.

of course, i have no idea how this can be solved...
the library is poorly documented and we have no support from their mailing list.

lubomir
--


More information about the subsurface mailing list