An open API service indexing awesome lists of open source software.

https://github.com/shuber/taggie

The tiniest little HTML/XML parser...using regex
https://github.com/shuber/taggie

Last synced: 8 months ago
JSON representation

The tiniest little HTML/XML parser...using regex

Awesome Lists containing this project

README

          

= taggie

The tiniest little HTML/XML parser...using regex

gem install taggie --pre

== WTF, why regex?!?

Curiosity, regex practice, and to understand the limitations of regular expressions

== Examples (these all may not work yet - work in progress)

html = '


Your Company


some content here

'.to_taggie
puts html.type # div
puts html.tag #

puts html.inner_html #

Your Company



puts html.children.first.src # logo.png
html.children.first.src = '/images/logo.png'
puts html.inner_html #

Your Company



p = html.siblings.first.children.first
puts p.tag #



p.id = 'content'
puts html.siblings.first.children.first #


Blah blah blah



p.class = nil
puts html.siblings.first.children.first #

Blah blah blah



p.class = ''
puts html.siblings.first.children.first #

Blah blah blah

== TODO

* siblings
* tests

== Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but
bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.