replace html parsing with text rendering and link parsing function

issue #37
This commit is contained in:
Morgan McMillian 2018-01-15 08:23:46 -08:00
parent fde3a7cdec
commit 3a2dee0979
2 changed files with 10 additions and 1 deletions

View file

@ -146,7 +146,7 @@ Container {
topMargin: ui.sdu(2.0) topMargin: ui.sdu(2.0)
bottomMargin: ui.sdu(2.0) bottomMargin: ui.sdu(2.0)
Label { Label {
text: Parser.parsePostData(ListItemData.content.html) text: Parser.parsePostText(ListItemData.content)
multiline: true multiline: true
textFormat: TextFormat.Html textFormat: TextFormat.Html
navigation.focusPolicy: NavigationFocusPolicy.NotFocusable navigation.focusPolicy: NavigationFocusPolicy.NotFocusable

View file

@ -17,6 +17,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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) { function parsePostData(t) {
t = t.replace(/&#033;/g,"\u0021"); t = t.replace(/&#033;/g,"\u0021");
t = t.replace(/&#034;/g,"\u0022"); t = t.replace(/&#034;/g,"\u0022");