Method: ArticleJSON::Import::GoogleDoc::HTML::TextParser#content

Defined in:
lib/article_json/import/google_doc/html/text_parser.rb

#contentString

The content of the text node, w/o any markup

Returns:

  • (String)


15
16
17
18
19
20
# File 'lib/article_json/import/google_doc/html/text_parser.rb', line 15

def content
  @node.children
    .map { |child| child.name == 'br' ? "\n" : child.inner_text }
    .join('')
    .gsub(/\s*\n\s*/, "\n") # Only keep a single consecutive linebreak
end