JSON Format for News Articles & Ruby Gem.
First, install the gem with gem install article_json
or add it to your Gemfile
via gem 'article_json'
.
require 'article_json'
# parse the HTML export of a Google Document
gdoc_parser = ArticleJSON::Import::GoogleDoc::HTML::Parser.new(google_doc_html)
elements = gdoc_parser.parsed_content
# initialize article-json format from storage
elements = ArticleJSON::Elements::Base.parse_json(json_string)
elements = ArticleJSON::Elements::Base.parse_hash_list(parsed_json)
# export parsed document as HTML
html_exporter = ArticleJSON::Export::HTML::Exporter.new(elements)
puts html_exporter.html
To load, parse and html-export the latest version of the reference document, run the following:
$ export DOC_ID=1E4lncZE2jDkbE34eDyYQmXKA9O26BHUiwguz4S9qyE8
$ ./bin/article_json_export_google_doc.rb $DOC_ID \
| ./bin/article_json_parse_google_doc.rb \
| ./bin/article_json_export_html.rb
A full example of the format can be found in the test fixtures: Parsed Reference Document
This Reference Document lists contains all supported formattings along with some descriptions.
The HTML exporter generates a HTML string for a list of elements. An example of the HTML export for the parsed reference document can be found here.
- Fork this repository
- Implement your feature or fix including Tests
- Update the change log
- Commit your changes with a meaningful commit message
- Create a pull request
Thank you!
See the list of contributors.
For the whole test suite, run bundle exec rspec
.
For individual tests, run bundle exec rspec spec/article_json/version_spec.rb
.
MIT License, see the license file.