[vlc-devel] [PATCH] macosx: Parse HTML descriptions in addons manager
Marvin Scholz
epirat07 at gmail.com
Thu Jul 7 03:32:06 CEST 2016
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.
---
modules/gui/macosx/AddonsWindowController.m | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/AddonsWindowController.m b/modules/gui/macosx/AddonsWindowController.m
index b770a32..fc23748 100644
--- a/modules/gui/macosx/AddonsWindowController.m
+++ b/modules/gui/macosx/AddonsWindowController.m
@@ -205,7 +205,14 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
[_name setStringValue:[currentItem name]];
[_author setStringValue:[currentItem author]];
[_version setStringValue:[currentItem version]];
- [_description setString:[currentItem description]];
+
+ // Parse HTML description properly
+ NSMutableString *htmlDescription = [NSMutableString stringWithString:@"<style>body{ font-family: -apple-system-body, -apple-system, HelveticaNeue, Arial, sans-serif; }</style>"];
+ [htmlDescription appendString:[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]];
}
--
2.7.4 (Apple Git-66)
More information about the vlc-devel
mailing list