Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

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