Skip to content

Instantly share code, notes, and snippets.

@NightWhistler
Created March 13, 2015 14:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NightWhistler/6e27af3f8b822a5ae734 to your computer and use it in GitHub Desktop.
Save NightWhistler/6e27af3f8b822a5ae734 to your computer and use it in GitHub Desktop.
Parse CSS links
public class CSSLinkHandler extends TagNodeHandler {
private static final Logger LOG = LoggerFactory.getLogger("CSSLinkHandler");
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end, SpanStack spanStack) {
String type = node.getAttributeByName("type");
String href = node.getAttributeByName("href");
LOG.debug("Found link tag: type=" + type + " and href=" + href );
if ( type == null || ! type.equals("text/css") ) {
LOG.debug("Ignoring link of type " + type );
}
//Load the href using HttpClient or something similar
}
}
//Register the CSSLinkHandler
HtmlSpanner mySpanner = new HtmlSpanner();
mySpanner.registerHandler("link", new CSSLinkHandler(textLoader));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment