htmld 0.1.0

Lightweight and forgiving HTML parser


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

htmld

Lightweight and forgiving HTML parser inspired by htmlparse2 by fb55

HTML Entity parsing and decoding are both optional. The current interface is based on callbacks, a ranged based interface is planned as well.

Example handler:

struct DOMBuilder {
    void onText(const(char)[] data) {}
    void onSelfClosing() {}
    void onOpenStart(const(char)[] data) {}
    void onOpenEnd(const(char)[] data) {}
    void onClose(const(char)[] data) {}
    void onAttrName(const(char)[] data) {}
    void onAttrEnd() {}
    void onAttrValue(const(char)[] data) {}
    void onComment(const(char)[] data) {}
    void onDeclaration(const(char)[] data) {}
    void onProcessingInstruction(const(char)[] data) {}
    void onCDATA(const(char)[] data) {}

    // the following are required if ParseEntities is set
    void onNamedEntity(const(char)[] data) {}
    void onNumericEntity(const(char)[] data) {}
    void onHexEntity(const(char)[] data) {}
    
    // required only if DecodeEntities is set
    void onEntity(const(char)[] data, const(char)[] decoded) {}
}

Example usage:

auto builder = DOMBuilder();
parseHTML(`<html><body>&nbsp;</body></html>`, builder);
Authors:
  • Márcio Martins
Dependencies:
none
Versions:
0.3.7 2019-Mar-14
0.3.6 2019-Jan-18
0.3.5 2019-Jan-17
0.3.4 2018-Nov-29
0.3.3 2018-Nov-08
Show all 31 versions
Download Stats:
  • 0 downloads today

  • 5 downloads this week

  • 46 downloads this month

  • 4341 downloads total

Score:
2.1
Short URL:
htmld.dub.pm