Created
June 10, 2014 03:59
-
-
Save ivan3bx/f4f4fdf2a0f6f5d05ce1 to your computer and use it in GitHub Desktop.
grabbing the last 200 characters preceeding a 'blockquote'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Brute force method of grabbing 200 characters preceeding first <blockquote> element | |
# | |
p = Post.last | |
parts = p.split_as_html | |
root = Nokogiri::HTML.fragment(parts.first.raw_content) | |
bq = root.search('blockquote')[1] | |
test_string = root.inner_html[(root.inner_html.index(bq.to_html) - 200)...(root.inner_html.index(bq.to_html))] | |
# ">\n<br><br><div class=\"gmail_quote\">On Tue, Jun 29, 2014 at 11:19 AM, John Smith <span dir=\"ltr\">< | |
# <a href=\"mailto:[email protected]\" target=\"_blank\">[email protected]</a>></span> wrote:<br>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment