Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

supports css stylesheet link in html #359

Closed
wants to merge 3 commits into from

1 participant

@yifan
<link rel="stylesheet" href="css.css" type="text/css"/>

is not supported. This pull request is to deal with this.

@yifan

Dah,,not clean

@yifan yifan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 19, 2013
  1. @yifan
Commits on Mar 25, 2013
  1. @yifan

    support css file

    yifan authored
  2. @yifan
This page is out of date. Refresh to see the latest.
View
16 Core/Source/DTHTMLAttributedStringBuilder.m
@@ -612,6 +612,22 @@ - (void)_registerTagEndHandlers
};
[_tagEndHandlers setObject:[styleBlock copy] forKey:@"style"];
+
+
+ void (^linkBlock)(void) = ^
+ {
+ // NSString *ref = [[_currentTag attributeForKey:@"rel"] lowercaseString];
+ NSString *href = [_currentTag attributeForKey:@"href"];
+ NSString *type = [[_currentTag attributeForKey:@"type"] lowercaseString];
+ if ([type isEqualToString:@"text/css"]) {
+ NSURL *stylesheetURL = [NSURL URLWithString:href relativeToURL:_baseURL];
+ NSString *stylesheetContent = [NSString stringWithContentsOfURL:stylesheetURL encoding:NSUTF8StringEncoding error:nil];
+ DTCSSStylesheet *localSheet = [[DTCSSStylesheet alloc] initWithStyleBlock:stylesheetContent];
+ [_globalStyleSheet mergeStylesheet:localSheet];
+ }
+ };
+
+ [ _tagEndHandlers setObject:[linkBlock copy] forKey:@"link"];
}
#pragma mark DTHTMLParser Delegate
View
4 DTCoreText.xcodeproj/project.pbxproj
@@ -500,6 +500,7 @@
A7F7EFC61573603100F5A4D0 /* DTImage+HTML.h in Headers */ = {isa = PBXBuildFile; fileRef = A7C5D01314D7E3BB00AF1D75 /* DTImage+HTML.h */; settings = {ATTRIBUTES = (Public, ); }; };
A7F7EFC81573603100F5A4D0 /* DTCompatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A672B91532F2D100920A18 /* DTCompatibility.h */; settings = {ATTRIBUTES = (Public, ); }; };
A7F842F416D38BC300BCD63F /* FontSizes.html in Resources */ = {isa = PBXBuildFile; fileRef = A7EB84FB168ED63A00D686B7 /* FontSizes.html */; };
+ DDCCEB1E17005A4F009FF923 /* css.css in Resources */ = {isa = PBXBuildFile; fileRef = DDCCEB1D17005A4F009FF923 /* css.css */; };
DE08BAB5148808B20054DC84 /* DTCoreTextFontOverrides.plist in Resources */ = {isa = PBXBuildFile; fileRef = A788CA2114863EF100E1AFD9 /* DTCoreTextFontOverrides.plist */; };
E2262DC71638331500BFDAD7 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7F5671C14D8469000D1F167 /* Cocoa.framework */; };
E2262DD51638336700BFDAD7 /* DTColor+HTML.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C95314863E8700E1AFD9 /* DTColor+HTML.m */; };
@@ -968,6 +969,7 @@
A7F5672514D8506B00D1F167 /* NSAttributedString+SmallCaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+SmallCaps.h"; sourceTree = "<group>"; };
A7F5672614D8506C00D1F167 /* NSAttributedString+SmallCaps.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+SmallCaps.m"; sourceTree = "<group>"; };
A7F7EFCD1573603100F5A4D0 /* libDTCoreText_no_DTFoundation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDTCoreText_no_DTFoundation.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ DDCCEB1D17005A4F009FF923 /* css.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = css.css; sourceTree = "<group>"; };
E2262DC61638331500BFDAD7 /* DTCoreText.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DTCoreText.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -1269,6 +1271,7 @@
A73885A41606E9B2001D60C4 /* EmojiTest.html */,
A730BCD616D29588003B849F /* Languages.html */,
A740369016E51C9800ECCDE0 /* About.html */,
+ DDCCEB1D17005A4F009FF923 /* css.css */,
);
path = Resources;
sourceTree = "<group>";
@@ -1970,6 +1973,7 @@
A7CF230A16DE1DF7005A4A6E /* AppledocSettings.plist in Resources */,
A740368916E51B3A00ECCDE0 /* DemoAboutViewController.xib in Resources */,
A740369116E51C9800ECCDE0 /* About.html in Resources */,
+ DDCCEB1E17005A4F009FF923 /* css.css in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
7 Demo/Resources/Video.html
@@ -4,6 +4,11 @@
<video width="320" height="240" src="http://shapeshed.com/examples/HTML5-video-element/video/320x240.m4v" loop="loop" x-webkit-airplay="allow" controls="controls">
Your browser doesn't support the video tag. You can <a href="http://shapeshed.com/examples/HTML5-video-element/video/320x240.m4v">download the video here.</a>
</video>
+
+<p>HTML5 video in different syntax</p>
+<video width="320" height="240">
+<source type="video/mp4" src="http://shapeshed.com/examples/HTML5-video-element/video/320x240.m4v"/>
+</video>
<h2>To Do</h2>
@@ -14,4 +19,4 @@
</ul>
<h2>YouTube in IFRAME</h2>
-<iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="480" src="http://www.youtube.com/embed/4L2IE2YD1wg?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" frameborder="0" allowfullscreen></iframe>
+<iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="480" src="http://www.youtube.com/embed/4L2IE2YD1wg?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" frameborder="0" allowfullscreen></iframe>
View
28 Demo/Resources/css.css
@@ -0,0 +1,28 @@
+ h1{
+ margin: 0px;
+ direction:rtl;
+ text-align:right;
+ }
+ .s2{
+ color: #000000;
+ font-size: 68.7500%;
+ font-style: normal;
+ font-variant: normal;
+ font-weight: normal;
+ letter-spacing: 0.0000em;
+ margin-bottom: 2.3148%;
+ margin-top: 0.0000%;
+ padding-left: 0.0000%;
+ padding-right: 0.0000%;
+ text-align: left;
+ text-decoration: none;
+ text-indent: 0.0000%;
+ text-transform: none;
+ }
+ .s18{
+ font-size: 81.2500%;
+ text-align: center;
+ }
+ .c10{
+ background: #FFFFFF;
+ }
View
10 Demo/Resources/styles.html
@@ -1,3 +1,8 @@
+<html>
+<head>
+<link rel="stylesheet" href="css.css" type="text/css"/>
+</head>
+<body>
<h1>CSS Styles Support</h1>
<p>Currently CSS styling is supported inline in tags, and via simple rules.</p>
<p>For example:</p>
@@ -51,3 +56,8 @@
<li>More robust mapping of font family to available fonts, support for fallback</li>
<li>text-decoration - blink, overline</li>
<li>font-variant - to support smallcaps</li></ul>
+
+<h1 class="s2 s18"><span class="c10">This text should be centered</span></h1>
+
+</body>
+</html>
View
2  Demo/Source/DemoTextViewController.m
@@ -161,6 +161,8 @@ - (NSAttributedString *)_attributedStringForSnippetUsingiOS6Attributes:(BOOL)use
[options setObject:[NSNumber numberWithBool:YES] forKey:DTUseiOS6Attributes];
}
+ [options setObject:[NSURL fileURLWithPath:readmePath] forKey:NSBaseURLDocumentOption];
+
NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data options:options documentAttributes:NULL];
return string;
Something went wrong with that request. Please try again.