crystagiri

An Html Reader / parser like Nokogiri Ruby gem html-parser-library
0.1.0 released

Cristagiri

An Html parser library for Crystal like amazing Nokogiri Ruby gem.

I not pretend that Cristagiri does much as Nokogiri. All help will be welcome! :)

Installation

Add this to your application's shard.yml:

dependencies:
  cristagiri:
    github: madeindjs/cristagiri

and then run

$ crystal deps

Usage

require "cristagiri"

Then you can simply instanciate a Cristagiri::HTML from a Html String like this

doc = Cristagiri::HTML.new "<h1>Cristagiri is awesome!!</h1>"

... or directly load it from a Web Url or a pathname:

doc = Cristagiri::HTML.from_file "README.md"
doc = Cristagiri::HTML.from_url "http://example.com/"

Then you can search XML::Node from Cristagiri::HTML instance:

# find by id
puts doc.at_id("main-content") # => <div id="main-content"> ... </div>

# find all tag by their classnames
doc.class("summary") { |node| puts node }
# => <div class="summary"> .. </div>
# => <div class="summary"> .. </div>
# => <div class="summary"> .. </div>

# find all tag by their types
doc.tag("h2") { |node| puts node }

Development

Clone this repository and go in it:

$ git clone https://github.com/madeindjs/cristagiri.git
$ cd cristagiri

You can generate the complete documentation with

$ crystal doc

And run spec tests to ensure all work correctly

$ crystal spec

Contributing

  1. Fork it ( https://github.com/madeindjs/cristagiri/fork )
  2. Create your feature branch git checkout -b my-new-feature
  3. Commit your changes git commit -am "Add some feature"
  4. Push to the branch git push origin my-new-feature
  5. Create a new Pull Request

Contributors

crystagiri:
  github: madeindjs/Crystagiri
  version: ~> 0.1.0
License MIT
Crystal 0.20.1

Authors

Dependencies 0

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently