From 5b0a94eca4c86b4a68be3aefaa17afe0d37d8b96 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 1 Feb 2020 06:53:58 -0800 Subject: [PATCH] fixed post rendering to properly display surrogate pair characters --- assets/PostItem.qml | 2 +- assets/parser.js | 29 +++++------------------------ 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/assets/PostItem.qml b/assets/PostItem.qml index 4583fa7..68faad0 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -149,7 +149,7 @@ Container { topMargin: ui.sdu(2.0) bottomMargin: ui.sdu(2.0) Label { - text: Parser.parsePostText(ListItemData.content) + text: Parser.fixPostHtml(ListItemData.content.html) multiline: true textFormat: TextFormat.Html navigation.focusPolicy: NavigationFocusPolicy.NotFocusable diff --git a/assets/parser.js b/assets/parser.js index c5baa81..c214bd3 100644 --- a/assets/parser.js +++ b/assets/parser.js @@ -17,27 +17,8 @@ * along with this program. If not, see . */ -function parsePostText(data) { - var t = data.text; - data.entities.links.forEach(function(link, indx) { - var ltext = t.substring(link.pos, link.pos + link.len); - var pretext = t.substring(0, link.pos); - var postext = t.substring(link.pos + link.len); - pretext = convert(pretext); - ltext = convert(ltext); - postext = convert(postext); - t = pretext + "" + ltext + "" + postext; - }); - return t; -} - -function convert(t) { - if (t.indexOf('