I’m rendering some HTML in a QT QLabel. The HTML looks like this:
<pre>foo\tbar</pre>
(note that I’ve put ‘\t’ where there is a tab chracter in the code).
This renders fine, but the tab character appears to be rendered as eight spaces, whereas I want it to be redered as 4. How can I change this without having to change the source HTML?
According to W3 (HTML4):
It’s implementation-defined, essencially. Most, if not all, browsers/renderers use eight spaces for tabs. This cannot be configured in Qt.
It is, however somewhat trivial to go through your HTML and replace tabs with however many spaces you wish. Write a simple parser for that. Pseudocode:
In case you’re curious, HTML3 specifies the use of eight-character tabs: