bugGNU Octave - Bugs: bug #45396, NEWS displayed in Qt GUI omits...


bug #45396: NEWS displayed in Qt GUI omits items which look like HTML

Submitter:  Rik <rik5>
Submitted:  Wed 24 Jun 2015 05:50:28 PM UTC
Category:  Documentation Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Wed 24 Jun 2015 09:51:55 PM UTC, comment #16: 

"the presents of []"

Oy, gee thanks.

Dan Sebald <sebald>
Wed 24 Jun 2015 09:48:06 PM UTC, comment #15: 

Sort of makes sense (i.e., why add html tags to the NEWS file contents just to convert them back to text), but there are some problems here:

1) QTextEdit is actually an HTML editor as well:

"QTextEdit is an advanced WYSIWYG viewer/editor supporting rich text formatting using HTML-style tags. It is optimized to handle large documents and to respond quickly to user input."

It recognizes the <pre></pre> tags, and when I remove those flags the contents of the release-notes window is missing all CRs.  It's just a single line of text.  There is a solution to this, which is to use the member function setPlainText() instead of setText().  That works, but then the font is not monospaced and the contents doesn't look good.  So, as strange as it seems, adding the HTML tags for &, >, <, <pre> and </pre> produces the nicer result in QTextBrowser/QTextEdit.  I could take it further and try selecting a font that has fixedPitch with plain text, but I'd rather not mess around with fonts for this.

2) CDATA code may have the same issue as the &/</>.  I tried your suggestion of <pre><![CDATA[…the original NEWS goes here…]]></pre>.  Both the QTextBrowser and SeaMonkey web browser do not display what is between <![CDATA[...]].  (If I move the ]] ahead some, whatever after it appears in the viewer.)  Also, for QTextBrowser the presents of [] in the release notes text caused leaves verbatim mode.  (See attached screen capture.)  I think we'd end up having to translate some characters in that case as well.

I think translating the & < and > characters are the easiest route to go given where things stand right now.

If anyone knows where the NEWS-4.0.html is constructed, that would help.  (BTW, SeaMonkey converts < to &lt; etc. when it saves the release notes HTML page to file.)

Dan Sebald <sebald>
Wed 24 Jun 2015 08:44:01 PM UTC, comment #14: 

Dan, the idea was to use <pre><![CDATA[…the original NEWS goes here…]]></pre>. However, your first example demonstrates that the HTML parser of Qt is not capable of CDATA :-/

Using <script> in the second example marks the whole text as JavaScript and therefore displays nothing.

For the Qt GUI I would use QTextEdit in readOnly mode, because you want to display a TEXT file without HTML markup.

On the web, where we explicitly have a .html file, I would use the pre+CDATA markup (plus html header, body and such).

Oliver Heimlich <oheim>
Wed 24 Jun 2015 08:25:08 PM UTC, comment #13: 

I forgot a character: the ampersand.  (New changeset attached.)

I was searching for where the NEWS files is converted to NEWS-x.x.html to fix that as well.  Couldn't find it, but grepping led to the function info_to_html(QString& text) that someone wrote inside libgui/src/qtinfo/parser.cc where I noticed ampersand was converted as well.  Makes sense.  I was going to make info_to_html() global and use that function instead, but it has a few extra doodads that might come as a surprise within the release notes.

(file #34311)

Dan Sebald <sebald>
Wed 24 Jun 2015 07:37:59 PM UTC, comment #12: 

Instead of <pre>...</pre>, I've tried

              news.prepend ("<![CDATA[");
              news.append ("]]>");


              news.prepend ("<script><![CDATA[");
              news.append ("]]></script>");

in the Qt interpreter.  Neither seem to work.  The former prints out the <![CDATA[ text and the latter produces a blank page.  What am I missing?

Dan Sebald <sebald>
Wed 24 Jun 2015 07:26:52 PM UTC, comment #11: 

Here's an alternate changeset that replaces < with &lt; and > with &gt; for the GUI, if you want to go that route.  Simple fix, appears to work.

(file #34310)

Dan Sebald <sebald>
Wed 24 Jun 2015 06:47:51 PM UTC, comment #10: 



Oliver Heimlich <oheim>
Wed 24 Jun 2015 06:46:29 PM UTC, comment #9: 

If the assumption is that the release notes will contain no HTML syntax such as links, it shouldn't be too difficult to write a script that translates all < to &lt and > to &gt.  Should I try that in Qt?

On the web-page side of things, when it comes time to build the files, sed could be used to do a similar thing.

Dan Sebald <sebald>
Wed 24 Jun 2015 06:44:24 PM UTC, comment #8: 

I want a pure <THIS_IS_REALLY_REALLY_VERBATIM> tag.  There doesn't appear to be one.  I don't want to have to process the text to add &lt; and &gt; markup.  I just want VERBATIM!!!

Anyway, I checked in a change for the NEWS file on stable and fixed the versions on the web.

In the past, I actually processed the NEWS file BY HAND to make it look pretty but I think that's just a lot of work that's not really important.  Unless we decide that we'll just maintain the NEWS file as an HTML document (not really great, we should be able to read it as a simple text document, I think) then we might as well just try to be careful to avoid anything that looks like something that could be screwed up inside a <pre> tag.

John W. Eaton <jwe>
Project Administrator
Wed 24 Jun 2015 06:38:32 PM UTC, comment #7: 

Oh, if it is multiple places that the text is used, and HTML is imposed in one place, then probably best to leave both places behave like HTML.  You are putting a verbatim-like HTML tag before and after, correct?  Internet search didn't turn up much.  Does this help:

Dan Sebald <sebald>
Wed 24 Jun 2015 06:32:09 PM UTC, comment #6: 

I agree with Rik, though that means we have to remember to not make the mistake again in the future.

Dan's fix is fine, but doesn't help us with the NEWS.html files that we have on the web.

John W. Eaton <jwe>
Project Administrator
Wed 24 Jun 2015 06:23:11 PM UTC, comment #5: 

I think we should just change the delimiter character to something else.  It may be cowardly, but it would take 5 minutes versus trying to figure out why the MIME type is incorrect.

Rik <rik5>
Project Administrator
Wed 24 Jun 2015 06:21:20 PM UTC, comment #4: 

QTextBrowser is derived from QTextEdit.  The attached changeset uses QTextEdit, but in read-only mode.

(file #34309)

Dan Sebald <sebald>
Wed 24 Jun 2015 06:21:10 PM UTC, comment #3: 

There is something fundamentally wrong with that document. It gets served with the text/html MIME type by the webserver, but contains no valid HTML.

Also, if it would contain (X)HTML, the XML separators “<>&"'” must always be encoded.

Oliver Heimlich <oheim>
Wed 24 Jun 2015 06:20:23 PM UTC, comment #2: 

Holy effing shit, even displaying plain unformatted uninterpreted text in an HTML document is complicated.  WTF is the world coming to?

John W. Eaton <jwe>
Project Administrator
Wed 24 Jun 2015 06:16:13 PM UTC, comment #1: 

The same thing happens with iceweasel using the NEWS.html file on the web.  In both cases, the text that the browser sees is surrounded by <pre> .. </pre>.  I guess my understanding of the <pre> tag in HTML is wrong.  I thought it really meant "display this text verbatim in a fixed-width font".

John W. Eaton <jwe>
Project Administrator
Wed 24 Jun 2015 05:50:28 PM UTC, original submission:  

The NEWS file for 4.0.0 contains the following:

 ** The internal class <Octave_map> was deprecated in Octave 3.8 and has
    been removed from Octave 4.0.  Replacement classes are
    <octave_map> (struct array) or <octave_scalar_map> for a single structure.

 ** The configure option --enable-octave-allocator has been removed.
    The internal class <octave_allocator> declared in oct-alloc.h has
    been removed.  The header remains, but is deprecated.  The macros to
    and DEFINE_OCTAVE_ALLOCATOR2) are now unconditionally defined to be

The problem is that the HTML viewer which reads the NEWS file and displays it in the GUI treats the class names which are surrounded by '<' and '>' as tags.

There might be a way to ask for verbatim display in the Qt viewer, or we could just use some other delimiter character in the NEWS file.

Rik <rik5>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #34310:  octave-convert_html_ltgt-djs2015jun24.patch added by sebald (908B - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by sebald (Updated the item)
  • -email is unavailable- added by oheim (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-24 rik5 Carbon-CopyRemoved 72865 -
    2015-06-24 sebald Attached File- Added Screenshot-Octave Release Notes.png, #34314
    2015-06-24 sebald Attached File- Added octave-convert_html_ampltgt-djs2015jun24.patch, #34311
    2015-06-24 sebald Attached File- Added octave-convert_html_ltgt-djs2015jun24.patch, #34310
    2015-06-24 jwe StatusNone Fixed
        Open/ClosedOpen Closed
    2015-06-24 sebald Attached File- Added octave-non_html_release_notes-djs2015jun24.patch, #34309

    Back to the top

    Powered by Savane 3.9