Skip to content

Devex/article_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

article_json

JSON Format for News Articles & Ruby Gem.

Status

Build Status Code Climate Coverage Status

Usage

First, install the gem with gem install article_json or add it to your Gemfile via gem 'article_json'.

Ruby

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

CLI

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

Format

A full example of the format can be found in the test fixtures: Parsed Reference Document

Import

Google Document Parser

This Reference Document lists contains all supported formattings along with some descriptions.

Export

HTML

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.

Contributing

  • 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.

Tests

For the whole test suite, run bundle exec rspec.

For individual tests, run bundle exec rspec spec/article_json/version_spec.rb.

License

MIT License, see the license file.

About

JSON Format for News Articles & Ruby Gem

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 9