[vlc-commits] macosx: Parse HTML descriptions in addons manager
Marvin Scholz
git at videolan.org
Thu Jul 7 14:28:46 CEST 2016
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Thu Jul 7 03:29:47 2016 +0200| [5cc28ae9c55bcbd3ac3d250ecb8830ef758d9fcb] | committer: Marvin Scholz
macosx: Parse HTML descriptions in addons manager
With this commit, HTML descriptions in the addons manager
are parsed correctly and formatting is applied using a
NSAttributedString and a little bit of CSS to make it use
the system font.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5cc28ae9c55bcbd3ac3d250ecb8830ef758d9fcb
---
modules/gui/macosx/AddonsWindowController.m | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/AddonsWindowController.m b/modules/gui/macosx/AddonsWindowController.m
index b770a32..784ade3 100644
--- a/modules/gui/macosx/AddonsWindowController.m
+++ b/modules/gui/macosx/AddonsWindowController.m
@@ -205,7 +205,13 @@ static void addonsEventsCallback( const vlc_event_t *event, void *data )
[_name setStringValue:[currentItem name]];
[_author setStringValue:[currentItem author]];
[_version setStringValue:[currentItem version]];
- [_description setString:[currentItem description]];
+
+ // Parse HTML description properly
+ NSMutableString *htmlDescription = [NSMutableString stringWithFormat:@"<style>body{ font-family: -apple-system-body, -apple-system, HelveticaNeue, Arial, sans-serif; }</style>%@", [currentItem description]];
+ [htmlDescription replaceOccurrencesOfString:@"\n" withString:@"<br />" options:NSLiteralSearch range:NSMakeRange(0, [htmlDescription length])];
+ NSAttributedString *attributedDescription = [[NSAttributedString alloc] initWithHTML:[htmlDescription dataUsingEncoding:NSUTF8StringEncoding]
+ documentAttributes:NULL];
+ [[_description textStorage] setAttributedString:attributedDescription];
[self updateInstallButton:[currentItem isInstalled]];
}
More information about the vlc-commits
mailing list