Git Product home page Git Product logo

htmlparsingrender's Introduction

HTMLParsingRender

HTMLParsingRender is an XML/HTML parser and render for Mac OS X and iOS . It Dependent on DTCoreText. It parse custom html tag and render by native

Preview

Register Class for custom tag

[DTTextAttachment registerClass:[TextAttachment class] forTagName:@"ws-text"];
        [DTTextAttachment registerClass:[ImageAttachment class] forTagName:@"ws-image"];
        [DTTextAttachment registerClass:[AudioAttachment class] forTagName:@"ws-audio"];  



_htmlView = [[HtmlView alloc] initWithFrame:self.view.bounds];
_htmlView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

[self.view addSubview:_htmlView];

NSString *readmePath = [[NSBundle mainBundle] pathForResource:@"Test.html" ofType:nil];
NSString *html = [NSString stringWithContentsOfFile:readmePath encoding:NSUTF8StringEncoding error:NULL];

[_htmlView bindHtmlString:html];

Custom view to render for native

_htmlView.customImageView = ^(NSString *imageURL, CGRect frame){

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
    [imageView sd_setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed: @"default"]];
    
    return imageView;
};


__weak typeof(self) weakSelf = self;
_htmlView.customAudioView = ^(NSString *audioURL, NSTimeInterval duration, CGRect frame){
    
    WSAudioView *audioView = [[NSBundle mainBundle] loadNibNamed:@"WSAudioView" owner:weakSelf options:nil].firstObject;
    audioView.frame = frame;
    audioView.audioUrl = audioURL;
    
    return audioView;
};

_htmlView.customTextView = ^(NSAttributedString *attributedString, CGRect frame){
    
    WSTextView *textView = [[WSTextView alloc] initWithFrame:frame];
    textView.attributedString = attributedString;
    
    return textView;
};

License:

The MIT License. See the LICENSE file for more infomation.

htmlparsingrender's People

Contributors

wishingsky avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.