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
- Host: GitHub
- URL: https://github.com/shuber/taggie
- Owner: shuber
- License: mit
- Created: 2010-04-02T08:56:38.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2011-03-12T21:22:33.000Z (about 15 years ago)
- Last Synced: 2025-02-09T14:04:06.758Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
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.