octodown 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +1 -2
- data/README.md +52 -26
- data/Rakefile +10 -0
- data/bin/octodown +6 -3
- data/lib/octodown/renderer/github_markdown.rb +4 -3
- data/lib/octodown/renderer/html.rb +4 -4
- data/lib/octodown/support/helpers.rb +5 -5
- data/lib/octodown/version.rb +1 -1
- data/spec/dummy/test.md +4 -1
- data/spec/markdown_generation_spec.rb +20 -1
- data/spec/template_rendering_spec.rb +2 -1
- data.tar.gz.sig +1 -3
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad582795e7cd14b58107e3c533ecfc71503f4d2
|
4
|
+
data.tar.gz: 71b248c82c33cb1d4ed0991531f79dec0fb58da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf4eb1f65e95f3b94a6b76814f854ba2cda0ad59aed4ebff05232689009e5cad6cf10aa1b4704274b1fa7c62bde43a439c992a0804a4d6d23ce3751f8e57eda9
|
7
|
+
data.tar.gz: 4c986a05888c0d05b48de4dcc726f1e3ff2fbaea6ca32447170d5cc197d8f45357431892081b6d65e1d4d6f7b958940ad89c69888df2f84e4941a2f315ecaaa8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,50 +1,75 @@
|
|
1
1
|
:octocat: octodown
|
2
2
|
==================
|
3
|
+
|
3
4
|
[](http://badge.fury.io/rb/octodown)
|
4
5
|
[](https://travis-ci.org/ianks/octodown)
|
5
6
|
|
6
|
-
|
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
|

|
11
17
|
|
18
|
+
-------------------------------------------------------------------------------
|
19
|
+
|
12
20
|
## Features:
|
13
21
|
|
14
|
-
|
15
|
-
- Yes emojis
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
-
|
20
|
-
- The `
|
21
|
-
|
22
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
60
|
+
- `octodown README.md`
|
61
|
+
|
38
62
|
2. Markdown preview styling:
|
39
|
-
|
63
|
+
- `octodown --style atom README.md`
|
64
|
+
|
40
65
|
3. *nix lovers:
|
41
|
-
|
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
|
-
|
47
|
-
|
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/
|
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.
|
61
|
-
5.
|
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,
|
40
|
+
puts Helpers.markdown_to_raw_html content, options, path
|
38
41
|
else
|
39
|
-
html_file = Helpers.markdown_to_html content,
|
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 =>
|
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, :
|
6
|
+
attr_reader :rendered_markdown, :style
|
7
7
|
|
8
|
-
def initialize(rendered_markdown,
|
8
|
+
def initialize(rendered_markdown, options)
|
9
9
|
@rendered_markdown = rendered_markdown
|
10
|
-
@
|
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
|
-
"#{
|
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,
|
8
|
-
html = markdown_to_raw_html(content,
|
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,
|
14
|
-
|
15
|
-
HTML.new(
|
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
|
data/lib/octodown/version.rb
CHANGED
data/spec/dummy/test.md
CHANGED
@@ -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(
|
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,
|
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
|
-
|
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.
|
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-
|
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
|