Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stephenwakely/hutamaul
Ruby gem to chop up html and ensure the output is still valid HTML
https://github.com/stephenwakely/hutamaul
Last synced: about 2 months ago
JSON representation
Ruby gem to chop up html and ensure the output is still valid HTML
- Host: GitHub
- URL: https://github.com/stephenwakely/hutamaul
- Owner: StephenWakely
- License: mit
- Created: 2011-02-01T16:08:12.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2012-08-10T10:44:53.000Z (over 12 years ago)
- Last Synced: 2024-04-12T16:07:59.805Z (10 months ago)
- Language: Ruby
- Homepage:
- Size: 121 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
== HutaMaul
Hutamaul is a simple html parser that will then split the html according to a given character count. It then churns out valid html, closing any tags that were discarded during the split.
To use:
html = "
some interesting textand then something okbit more"# This will split the html at the closest word break to 25 characters.
split_html = Hutamaul.split(html, 25);# This will split the html at the closes word break to 22 characters and add a ... to the end
split_html = Hutamaul.split(html, 25, '...')# Further options can be set on a tag by tag basis.
split_html = Hutamaul.split(html, 25, '...') do |options|# Text within a
tag gets split before the current line
options.code { |split| split.before_line }# All other text will get split at the requested character.
options.else { |split| split.at_character }
end