Wed 24 Jun 2015 09:51:55 PM UTC, comment #16:
"the presents of []"
Oy, gee thanks.
|
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 < etc. when it saves the release notes HTML page to file.)
(file #34314)
|
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).
|
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)
|
Wed 24 Jun 2015 07:37:59 PM UTC, comment #12:
Instead of <pre>...</pre>, I've tried
and
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?
|
Wed 24 Jun 2015 07:26:52 PM UTC, comment #11:
Here's an alternate changeset that replaces < with < and > with > for the GUI, if you want to go that route. Simple fix, appears to work.
(file #34310)
|
Wed 24 Jun 2015 06:47:51 PM UTC, comment #10:
The <THIS_IS_REALLY_REALLY_VERBATIM> tag is called CDATA
http://www.w3schools.com/xml/xml_cdata.asp
|
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 < and > to >. 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.
|
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 < and > 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.
|
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:
http://thomas-cokelaer.info/blog/2011/03/html-how-to-insert-html-code-in-a-verbatim-tag/
|
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.
|
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.
|
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)
|
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.
|
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?
|
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".
|
Wed 24 Jun 2015 05:50:28 PM UTC, original submission:
The NEWS file for 4.0.0 contains the following:
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.
|