replace html parsing with text rendering and link parsing function
issue #37
This commit is contained in:
parent
fde3a7cdec
commit
3a2dee0979
2 changed files with 10 additions and 1 deletions
|
@ -146,7 +146,7 @@ Container {
|
|||
topMargin: ui.sdu(2.0)
|
||||
bottomMargin: ui.sdu(2.0)
|
||||
Label {
|
||||
text: Parser.parsePostData(ListItemData.content.html)
|
||||
text: Parser.parsePostText(ListItemData.content)
|
||||
multiline: true
|
||||
textFormat: TextFormat.Html
|
||||
navigation.focusPolicy: NavigationFocusPolicy.NotFocusable
|
||||
|
|
|
@ -17,6 +17,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function parsePostText(data) {
|
||||
var t = data.text;
|
||||
data.entities.links.forEach(function(link, indx) {
|
||||
var ltext = t.substring(link.pos, link.pos + link.len);
|
||||
t = t.substring(0, link.pos) + "<a href=\"" + link.link + "\">" + ltext + "</a>" + t.substring(link.pos + link.len);
|
||||
});
|
||||
return t;
|
||||
}
|
||||
|
||||
function parsePostData(t) {
|
||||
t = t.replace(/!/g,"\u0021");
|
||||
t = t.replace(/"/g,"\u0022");
|
||||
|
|
Reference in a new issue