octodown 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bce562e8fb22b507adb9254a3a477e580e8476aa
4
- data.tar.gz: 8bad0909539c3c0ec5976b899e3d8591db901b7c
3
+ metadata.gz: dad582795e7cd14b58107e3c533ecfc71503f4d2
4
+ data.tar.gz: 71b248c82c33cb1d4ed0991531f79dec0fb58da2
5
5
  SHA512:
6
- metadata.gz: 52a608f823bea53fd6bfc09ba7cc4c5f5c40954d7977e798a6635c040e68e252c55c6013f1034b0e9e0ee574c7b0b24e694312f5c34ee0edd6d80702916e972a
7
- data.tar.gz: 5e4d3e21b4127e3ac90ea4edbbc85231b771953c57ff1844f3490e218a92447c12bbc27d4ed4b24d17ccbf8e81e3adbcde6ad0b0276293218d77843fe6df90f9
6
+ metadata.gz: bf4eb1f65e95f3b94a6b76814f854ba2cda0ad59aed4ebff05232689009e5cad6cf10aa1b4704274b1fa7c62bde43a439c992a0804a4d6d23ce3751f8e57eda9
7
+ data.tar.gz: 4c986a05888c0d05b48de4dcc726f1e3ff2fbaea6ca32447170d5cc197d8f45357431892081b6d65e1d4d6f7b958940ad89c69888df2f84e4941a2f315ecaaa8
checksums.yaml.gz.sig CHANGED
Binary file
data/.travis.yml CHANGED
@@ -5,8 +5,7 @@ before_install:
5
5
  - sudo apt-get install -y libicu-dev build-essential
6
6
  install: 'bundle install'
7
7
  script:
8
- - 'bundle exec rspec --format documentation'
9
- - 'bundle exec rubocop'
8
+ - bundle exec rake
10
9
  rvm:
11
10
  - '2.2.0'
12
11
  - '2.1.4'
data/README.md CHANGED
@@ -1,50 +1,75 @@
1
1
  :octocat: octodown
2
2
  ==================
3
+
3
4
  [![GemVersion](https://badge.fury.io/rb/octodown.svg)](http://badge.fury.io/rb/octodown)
4
5
  [![Build Status](https://travis-ci.org/ianks/octodown.svg)](https://travis-ci.org/ianks/octodown)
5
6
 
6
- Ever wanted to easily preview what you markdown would look like *exactly* on
7
+
8
+ Ever wanted to easily preview what you markdown would look like _exactly_ on
7
9
  Github? Ever wanted to do that from inside of a Terminal? Well this Gem is for
8
10
  you. Dead simple. Never get caught writing ugly markdown again.
9
11
 
12
+ Octodown uses the same parsers and CSS and Github uses for their markdown
13
+ rendering. Github markdown styling looks beautiful, so it is Octodown's
14
+ primary goal to reproduce it as faithfully as possible.
15
+
10
16
  ![Octodown GIF](assets/octodown.gif?raw=true)
11
17
 
18
+ -------------------------------------------------------------------------------
19
+
12
20
  ## Features:
13
21
 
14
- * Uses the same markdown parsers and CSS as Github for true duplication.
15
- - Yes emojis *are* included.
16
- * Fast. `octodown` uses native parsers to ensure performance.
17
- * Multiple CSS styles. Choose from either.
18
- - `$ octodown --style atom README.md`
19
- - The `github.com` markdown (default)
20
- - The `Atom` text editor markdown
21
- * Properly parses `STDIN`.
22
- - `$ cat README.md | octodown`
22
+ - Uses the same markdown parsers and CSS as Github for true duplication.
23
+ - Yes emojis _are_ included. :smiling_imp:
24
+
25
+ - Fast. `octodown` uses native parsers to ensure performance.
26
+ - Multiple CSS styles.
27
+ - `octodown --style atom README.md`
28
+ - The `--github` markdown (default)
29
+ - The `--atom` text editor markdown
30
+
31
+ - Properly parses `STDIN`.
32
+ - `cat README.md | octodown`
23
33
 
24
34
  ## Installation
25
35
 
26
36
  1. Install `icu4c` and `cmake`:
27
- * Mac: `$ brew install icu4c cmake`
28
- * Apt: `$ sudo apt-get install -y libicu-dev cmake`
29
- 2. If you have a non-system Ruby (*highly recommended*):
30
- * `$ gem install octodown`
31
- 3. Else:
32
- * `$ sudo gem install octodown`
37
+ - Mac: `brew install icu4c cmake`
38
+ - Apt: `sudo apt-get install -y libicu-dev cmake`
39
+
40
+ 2. Install octodown:
41
+ - If you have a non-system Ruby (_highly recommended_): `gem install
42
+ octodown`
43
+ - Else: `sudo gem install octodown`
44
+
45
+ 4. Install in VIM (_optional_):
46
+ - Use [Dispatch](https://github.com/tpope/vim-dispatch) and add this to
47
+ your .vimrc:
48
+
49
+ ```viml
50
+ " Use octodown as default build command for Markdown files
51
+ autocmd FileType markdown let b:dispatch = 'octodown %'
52
+ ```
53
+ - Caveat: make sure you follow the directions on the Dispatch README.md and
54
+ make sure that the correct version of Ruby (the one which as Octodown
55
+ install as a Gem), is used.
33
56
 
34
57
  ## Usage
35
58
 
36
59
  1. Basic:
37
- * `$ octodown README.md`
60
+ - `octodown README.md`
61
+
38
62
  2. Markdown preview styling:
39
- * `$ octodown --style atom README.md`
63
+ - `octodown --style atom README.md`
64
+
40
65
  3. *nix lovers:
41
- * `$ echo '# Hello world!' | octodown --raw > index.html`
66
+ - `echo '# Hello world!' | octodown --raw > index.html`
42
67
 
43
68
  ## Notes
44
69
 
45
70
  1. With no arguments given, octodown will read `STDIN` until `EOF` is reached.
46
- * In order to work with this mode, type what you want into the input, then press
47
- `Ctrl-D` when finished.
71
+ - In order to work with this mode, type what you want into the input, then press
72
+ `Ctrl-D` when finished.
48
73
  2. `octodown` attempts to use default OS support for opening HTML files from
49
74
  terminal. In Mac, this would be the `open` command; for Linux it is either
50
75
  `xdg-open` or `x-www-browser`. If these are not set, octodown will not
@@ -54,8 +79,9 @@ you. Dead simple. Never get caught writing ugly markdown again.
54
79
 
55
80
  ## Contributing
56
81
 
57
- 1. Fork it ( https://github.com/[my-github-username]/octodown/fork )
58
- 2. Create your feature branch (`git checkout -b my-new-feature`)
59
- 3. Commit your changes (`git commit -am 'Add some feature'`)
60
- 4. Push to the branch (`git push origin my-new-feature`)
61
- 5. Create a new Pull Request
82
+ 1. Fork it ( https://github.com/ianks/octodown/fork )
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Run the test suite (`bundle exec rake`)
86
+ 5. Push to the branch (`git push origin my-new-feature`)
87
+ 6. Create a new Pull Request
data/Rakefile CHANGED
@@ -2,6 +2,16 @@ require 'bundler/gem_tasks'
2
2
  require 'open-uri'
3
3
  require 'fileutils'
4
4
  require 'tempfile'
5
+ require 'rspec/core/rake_task'
6
+ require 'rubocop/rake_task'
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ RSpec::Core::RakeTask.new :spec do |task|
11
+ task.rspec_opts = '--format documentation'
12
+ end
13
+
14
+ task :default => [:spec, :rubocop]
5
15
 
6
16
  task :styles do
7
17
  begin
data/bin/octodown CHANGED
@@ -20,6 +20,10 @@ OptionParser.new do |opts|
20
20
  options[:raw] = r
21
21
  end
22
22
 
23
+ opts.on('-g', '--[no-]gfm', 'Use for non-README files (comments, etc)') do |g|
24
+ options[:gfm] = g
25
+ end
26
+
23
27
  opts.on_tail('-h', '--help', 'Show this message') do
24
28
  puts opts
25
29
  exit
@@ -30,13 +34,12 @@ def main(options)
30
34
  include Octodown::Support
31
35
 
32
36
  content = ARGF.read
33
- style = options[:style] || 'github'
34
37
  path = File.dirname(File.expand_path(ARGF.path))
35
38
 
36
39
  if options[:raw]
37
- puts Helpers.markdown_to_raw_html content, style, path
40
+ puts Helpers.markdown_to_raw_html content, options, path
38
41
  else
39
- html_file = Helpers.markdown_to_html content, style, path
42
+ html_file = Helpers.markdown_to_html content, options, path
40
43
  Browser.new.open html_file
41
44
  end
42
45
  end
@@ -5,11 +5,12 @@ require 'html/pipeline'
5
5
  module Octodown
6
6
  module Renderer
7
7
  class GithubMarkdown
8
- attr_reader :content, :document_root
8
+ attr_reader :content, :document_root, :gfm
9
9
 
10
- def initialize(content, document_root)
10
+ def initialize(content, document_root, options = {})
11
11
  @content = content
12
12
  @document_root = document_root
13
+ @gfm = options[:gfm] || false
13
14
  end
14
15
 
15
16
  def to_html
@@ -34,7 +35,7 @@ module Octodown
34
35
  ::HTML::Pipeline::MentionFilter,
35
36
  ::HTML::Pipeline::EmojiFilter,
36
37
  ::HTML::Pipeline::SyntaxHighlightFilter
37
- ], context.merge(:gfm => true)
38
+ ], context.merge(:gfm => gfm)
38
39
  end
39
40
  end
40
41
  end
@@ -3,11 +3,11 @@ require 'erb'
3
3
  module Octodown
4
4
  module Renderer
5
5
  class HTML
6
- attr_reader :rendered_markdown, :template
6
+ attr_reader :rendered_markdown, :style
7
7
 
8
- def initialize(rendered_markdown, template)
8
+ def initialize(rendered_markdown, options)
9
9
  @rendered_markdown = rendered_markdown
10
- @template = template
10
+ @style = options[:style] || 'github'
11
11
  end
12
12
 
13
13
  def render
@@ -24,7 +24,7 @@ module Octodown
24
24
  stylesheet_file = File.join(
25
25
  Octodown.root,
26
26
  'assets',
27
- "#{template}.css"
27
+ "#{style}.css"
28
28
  )
29
29
 
30
30
  File.read stylesheet_file
@@ -4,15 +4,15 @@ module Octodown
4
4
  include Octodown::Renderer
5
5
 
6
6
  # TODO: Find a better home for this logic
7
- def self.markdown_to_html(content, template, path)
8
- html = markdown_to_raw_html(content, template, path)
7
+ def self.markdown_to_html(content, options, path)
8
+ html = markdown_to_raw_html(content, options, path)
9
9
  tmp = Octodown::Support::HTMLFile.new 'octodown'
10
10
  tmp.persistent_write html
11
11
  end
12
12
 
13
- def self.markdown_to_raw_html(content, template, path)
14
- unstyled_html = GithubMarkdown.new(content, path).to_html
15
- HTML.new(unstyled_html, template).render
13
+ def self.markdown_to_raw_html(content, options, path)
14
+ rendered_markdown = GithubMarkdown.new(content, path, options).to_html
15
+ HTML.new(rendered_markdown, options).render
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Octodown
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
data/spec/dummy/test.md CHANGED
@@ -1,4 +1,7 @@
1
- # Hello world!
1
+ Hello world!
2
+ ============
3
+ ![some-img](https://foo.com/bar.img)
4
+ ![some-img](https://foo.com/bar.img)
2
5
 
3
6
  You are now reading markdown. How lucky you are!
4
7
 
@@ -2,8 +2,9 @@ require 'tempfile'
2
2
 
3
3
  describe Octodown::Renderer::GithubMarkdown do
4
4
  let(:dummy_path) { File.join(File.dirname(__FILE__), 'dummy', 'test.md') }
5
+ let(:content) { File.read dummy_path }
5
6
  let(:html) do
6
- Octodown::Renderer::GithubMarkdown.new(File.read(dummy_path), 'tmp').to_html
7
+ Octodown::Renderer::GithubMarkdown.new(content, 'tmp').to_html
7
8
  end
8
9
 
9
10
  it 'create HTML from markdown file' do
@@ -16,4 +17,22 @@ describe Octodown::Renderer::GithubMarkdown do
16
17
  it 'highlights the code' do
17
18
  expect(html).to include 'highlight-ruby'
18
19
  end
20
+
21
+ describe 'when :gfm option is set' do
22
+ context 'true' do
23
+ it 'renders hard-wraps' do
24
+ options = { :gfm => true }
25
+ doc = Octodown::Renderer::GithubMarkdown.new(content, 'tmp', options)
26
+ expect(doc.to_html).to include '<br>'
27
+ end
28
+ end
29
+
30
+ context 'false' do
31
+ it 'does not render hard-wraps' do
32
+ options = { :gfm => false }
33
+ doc = Octodown::Renderer::GithubMarkdown.new(content, 'tmp', options)
34
+ expect(doc.to_html).to_not include '<br>'
35
+ end
36
+ end
37
+ end
19
38
  end
@@ -2,11 +2,12 @@ require 'tempfile'
2
2
 
3
3
  describe Octodown::Renderer::HTML do
4
4
  let(:dummy_path) { File.join(File.dirname(__FILE__), 'dummy', 'test.md') }
5
+ let(:options) { { style: 'github' } }
5
6
  let(:html) do
6
7
  Octodown::Renderer::GithubMarkdown.new(File.read(dummy_path), 'tmp').to_html
7
8
  end
8
9
 
9
- subject { Octodown::Renderer::HTML.new(html, 'github').render }
10
+ subject { Octodown::Renderer::HTML.new(html, options).render }
10
11
 
11
12
  before { allow(Octodown).to receive(:root) { '.' } }
12
13
 
data.tar.gz.sig CHANGED
@@ -1,3 +1 @@
1
- l9!/:!�N����.� ��m��B&�$&��а���ǝxR�D(Y`�ٛ�!�@���M�|P
2
- z' �c�A;k���{����0z�J���\�M(�k�|�yNv�D�T��JYk3O
3
- �|�>.@��OWF,ײ ��lDZ���s��_&=9E�&���VH�T�aA˿SV�9��܅)�� `�S��[�F}�T�HXl�t���F��cUOa
1
+ ,����t�n��+՞��OS<��U����u�dVQ�@{��)`�|7�E��x!�w����"�N�}�3i�9�r�uh��uҺU�_zt�� ���e�S����V:U&�@����SIRHLw#Ƴ:��2�y��5%�������f������Dzk�q��8���\G�Ewm(�G�;�7�m�)8����3��eG�#��)��d˛#�B��$��r�<��䁇>�K���%�-D)�U5(����]G
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octodown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
@@ -30,7 +30,7 @@ cert_chain:
30
30
  YGBeYMyEy7Q4wf7k4k5yyDUZyyaeg0DF/kNEN5llspJ9DHMP2cQqOiH+IQSNiUhR
31
31
  32sJqaZRHeJLDhZPLi5yXItTsQnPy6uob2oyypwFYTM=
32
32
  -----END CERTIFICATE-----
33
- date: 2015-01-03 00:00:00.000000000 Z
33
+ date: 2015-01-07 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: github-markup
metadata.gz.sig CHANGED
Binary file