styledown 1.0.2.pre.0 → 2.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -8
- data/History.md +18 -6
- data/Notes.md +2 -68
- data/Rakefile +2 -7
- data/Readme.md +21 -15
- data/lib/styledown/version.rb +1 -1
- data/lib/styledown.rb +11 -7
- data/styledown.gemspec +3 -3
- data/test/fixtures/simple/other_sample.md +3 -0
- data/test/test.rb +38 -42
- data/test/test_helper.rb +3 -3
- data/vendor/dist/styledown.js +22576 -42343
- metadata +18 -7
- data/Gemfile.lock +0 -18
- data/test/fixtures/simple/sample.css +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e42a396f82037aed88126bf20330f0bb452afdce
|
4
|
+
data.tar.gz: afe588018af86b3612eb3fef0ac60647281efcd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe33b286ca2127789c929b2ec4b6c1ebbe805d716ef8fc221ba384a2bef4a45285c49ed26b592cd899f5f947460a8e79bc4a8af4d75fa8d8b78df17a62ca9e17
|
7
|
+
data.tar.gz: 9d863cbaf3fc980ad3ee3fc6e2e69b4e065f95ec06d4844e4922d9fd3b58256108f907939045ab9f4bf93fb21fc5c966711695fdf646affb457edc9df3ecb7ad
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/History.md
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
-
##
|
1
|
+
## [v2.0.0-pre1]
|
2
|
+
> May 6, 2016
|
2
3
|
|
3
|
-
|
4
|
+
- **Completely new API.** Update to use Styledown v2.0.0-pre1.
|
4
5
|
|
5
|
-
|
6
|
+
[v2.0.0-pre1]: https://github.com/styledown/styledown-rails/compare/v0.0.0...v2.0.0-pre1
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
## [v1.0.1]
|
9
|
+
> Apr 19, 2016
|
9
10
|
|
10
|
-
|
11
|
+
- Release as a non-prerelease-version. No functional changes.
|
12
|
+
|
13
|
+
[v1.0.1]: https://github.com/styledown/styledown-rails/compare/v1.0.1.pre.0...v1.0.1
|
14
|
+
|
15
|
+
## v1.0.1.pre.0
|
16
|
+
> September 5, 2014
|
17
|
+
|
18
|
+
- Update Styledown source to 1.0.1.
|
19
|
+
- Add support for `Styledown.parse(array of files)`.
|
20
|
+
|
21
|
+
## v0.7.0.pre.0
|
22
|
+
> September 1, 2014
|
11
23
|
|
12
24
|
Initial pre-release. No Rails integration, but plain Ruby integration works.
|
data/Notes.md
CHANGED
@@ -3,11 +3,8 @@ Developer notes
|
|
3
3
|
|
4
4
|
### Updating source
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
This will update `vendor/dist/styledown.js`. Get it as `dist/styledown.js` from
|
9
|
-
the [styledown/styledown] repo. This is built using the `npm run prepublish`
|
10
|
-
hook.
|
6
|
+
Update `vendor/dist/styledown.js`. Get it as `dist/styledown.js` from the
|
7
|
+
[styledown/styledown] repo. This is built using the `npm run prepublish` hook.
|
11
8
|
|
12
9
|
[styledown/styledown]: https://github.com/styledown/styledown
|
13
10
|
|
@@ -17,66 +14,3 @@ hook.
|
|
17
14
|
bump lib/styledown/version.rb
|
18
15
|
gem build *.gemspec
|
19
16
|
rake && gem push *.gem && git release v1.0.0
|
20
|
-
|
21
|
-
Planned API
|
22
|
-
-----------
|
23
|
-
|
24
|
-
### Globbing
|
25
|
-
|
26
|
-
Globbing should be supported to make things convenient.
|
27
|
-
|
28
|
-
```rb
|
29
|
-
Styledown.parse([
|
30
|
-
Rails.root.join('app/assets/stylesheets/*/*.less')
|
31
|
-
])
|
32
|
-
```
|
33
|
-
|
34
|
-
### Controller integration
|
35
|
-
|
36
|
-
There should be better Rails integration later on. It'd be nice to be able to
|
37
|
-
simplify controller integration like so. (This should take caching into
|
38
|
-
consideration)
|
39
|
-
|
40
|
-
```rb
|
41
|
-
module StyleguidesController
|
42
|
-
layout 'styleguide'
|
43
|
-
|
44
|
-
def show
|
45
|
-
render styleguide: CSS_PATHS
|
46
|
-
end
|
47
|
-
|
48
|
-
CSS_PATHS = [
|
49
|
-
'app/assets/stylesheets/components/*',
|
50
|
-
'app/assets/stylesheets/overrides/*',
|
51
|
-
'app/assets/stylesheets/foobar/*',
|
52
|
-
]
|
53
|
-
end
|
54
|
-
```
|
55
|
-
|
56
|
-
### Generator
|
57
|
-
|
58
|
-
It'd be nice to do `rails g styledown:install` and have these things in place:
|
59
|
-
|
60
|
-
```rb
|
61
|
-
# config/routes.rb
|
62
|
-
get '/styleguides' => 'styleguides#show'
|
63
|
-
```
|
64
|
-
|
65
|
-
```rb
|
66
|
-
# app/controllers/styleguides_controller.rb
|
67
|
-
module StyleguidesController
|
68
|
-
# ... see above
|
69
|
-
end
|
70
|
-
```
|
71
|
-
|
72
|
-
```html
|
73
|
-
<!-- app/views/layouts/styleguide.html.erb -->
|
74
|
-
<html>
|
75
|
-
<head>
|
76
|
-
<meta charset='utf-8'>
|
77
|
-
</head>
|
78
|
-
<body>
|
79
|
-
<%= yield %>
|
80
|
-
</body>
|
81
|
-
</html>
|
82
|
-
```
|
data/Rakefile
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
-
|
3
|
+
|
4
4
|
Rake::TestTask.new do |t|
|
5
5
|
t.test_files = Dir.glob('test/**/*test.rb')
|
6
6
|
end
|
7
|
-
|
8
|
-
task :default => :test
|
9
7
|
|
10
|
-
|
11
|
-
task :update do
|
12
|
-
system "wget https://github.com/styledown/styledown/raw/master/dist/styledown.js -O vendor/dist/styledown.js"
|
13
|
-
end
|
8
|
+
task default: :test
|
data/Readme.md
CHANGED
@@ -10,41 +10,47 @@ Ruby integration of [Styledown].
|
|
10
10
|
|
11
11
|
```rb
|
12
12
|
# Gemfile
|
13
|
-
gem 'styledown'
|
13
|
+
gem 'styledown', '~> 2.0.0'
|
14
14
|
```
|
15
15
|
|
16
16
|
[![Gem](https://img.shields.io/gem/v/styledown.svg?style=flat)](http://rubygems.org/gems/styledown "View this project in Rubygems")
|
17
17
|
|
18
18
|
## Plain Ruby integration
|
19
19
|
|
20
|
-
|
20
|
+
These are provided:
|
21
|
+
|
22
|
+
* `Styledown.parse`
|
23
|
+
* `Styledown.parse_files`
|
24
|
+
* `Styledown.render`
|
25
|
+
|
26
|
+
API them is exactly the same as the JS version ([docs]).
|
21
27
|
|
22
28
|
```rb
|
23
29
|
require 'styledown'
|
24
30
|
|
25
|
-
# Passing a Styledown sting:
|
26
|
-
Styledown.parse('### hello', bare: true)
|
27
|
-
|
28
31
|
# Parsing files from disk:
|
29
|
-
Styledown.
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
data = Styledown.parse_files([
|
33
|
+
'/path/to/buttons.md',
|
34
|
+
'/path/to/forms.md',
|
35
|
+
'...'
|
33
36
|
])
|
34
37
|
|
35
38
|
# Parsing files from elsewhere:
|
36
|
-
Styledown.parse([
|
37
|
-
{ name:
|
38
|
-
{ name:
|
39
|
+
data = Styledown.parse([
|
40
|
+
{ name: 'buttons.md', contents: '### hi from buttons' },
|
41
|
+
{ name: 'forms.md', contents: '### hi from forms' },
|
39
42
|
])
|
43
|
+
|
44
|
+
# Rendering a page:
|
45
|
+
html = Styledown.render(data, 'buttons.md')
|
46
|
+
html = Styledown.render(data, 'forms.md')
|
40
47
|
```
|
41
48
|
|
42
|
-
|
43
|
-
[docs]: https://github.com/styledown/styledown/blob/master/docs/API.md#styledownparse
|
49
|
+
[docs]: https://github.com/styledown/styledown/blob/v2/docs/api.md#styledownparse
|
44
50
|
|
45
51
|
## :copyright:
|
46
52
|
|
47
|
-
**styledown** © 2014
|
53
|
+
**styledown** © 2014-2016, Rico Sta. Cruz. Released under the [MIT License].<br>
|
48
54
|
Authored and maintained by Rico Sta. Cruz with help from [contributors].
|
49
55
|
|
50
56
|
> [ricostacruz.com](http://ricostacruz.com) ·
|
data/lib/styledown/version.rb
CHANGED
data/lib/styledown.rb
CHANGED
@@ -12,22 +12,26 @@ module Styledown
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def parse(source, options={})
|
16
|
-
if array_of_filenames?(source)
|
17
|
-
source = unpack_files(source)
|
18
|
-
end
|
19
|
-
|
15
|
+
def parse(source, options = {})
|
20
16
|
context.call('Styledown.parse', source, options)
|
21
17
|
end
|
22
18
|
|
19
|
+
def parse_files(source, options = {})
|
20
|
+
parse unpack_files(source), options
|
21
|
+
end
|
22
|
+
|
23
|
+
def render(data, file, options = {})
|
24
|
+
context.call('Styledown.render', data, file, options)
|
25
|
+
end
|
26
|
+
|
23
27
|
def js_version
|
24
28
|
context.eval('Styledown.version')
|
25
29
|
end
|
26
30
|
|
27
|
-
private
|
31
|
+
private
|
28
32
|
|
29
33
|
def unpack_files(source)
|
30
|
-
source.map { |file| { name: file,
|
34
|
+
source.map { |file| { name: file, contents: File.read(file) } }
|
31
35
|
end
|
32
36
|
|
33
37
|
def array_of_filenames?(source)
|
data/styledown.gemspec
CHANGED
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.author = 'Rico Sta. Cruz'
|
16
16
|
s.email = 'hi@ricostacruz.com'
|
17
|
-
s.homepage = 'http://github.com/styledown/styledown-
|
17
|
+
s.homepage = 'http://github.com/styledown/styledown-rails'
|
18
18
|
s.license = 'MIT'
|
19
19
|
|
20
|
-
s.add_dependency 'execjs', '>= 0'
|
21
|
-
s.add_development_dependency 'rake', '>= 0'
|
20
|
+
s.add_dependency 'execjs', '>= 0', '< 3'
|
21
|
+
s.add_development_dependency 'rake', '>= 0', '< 12'
|
22
22
|
end
|
data/test/test.rb
CHANGED
@@ -1,69 +1,65 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
3
|
+
describe 'Styledown.js_version' do
|
4
|
+
it 'produces a string' do
|
5
5
|
Styledown.js_version.must_match /^\d+\.\d+\.\d+/
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe 'Basic parsing' do
|
10
10
|
before do
|
11
|
-
@
|
11
|
+
@data = Styledown.parse([{
|
12
|
+
name: 'buttons.md',
|
13
|
+
contents: '### hi'
|
14
|
+
}])
|
12
15
|
end
|
13
16
|
|
14
|
-
it
|
15
|
-
@
|
17
|
+
it 'works' do
|
18
|
+
@data['files'].must_be_kind_of Hash
|
19
|
+
@data['files']['buttons.md'].must_be_kind_of Hash
|
20
|
+
@data['files']['buttons.md']['sections'].must_be_kind_of Hash
|
16
21
|
end
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
23
|
+
describe 'with rendering' do
|
24
|
+
before do
|
25
|
+
@output = Styledown.render(@data, 'buttons.md')
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
{ :name => "input.md", :data => "### hi from md" },
|
27
|
-
{ :name => "input.css", :data => "/**\n * hi from css:\n * world\n */" }
|
28
|
-
])
|
29
|
-
end
|
28
|
+
it 'produces an HTML fragment' do
|
29
|
+
@output.must_match /<h3[^>]+>hi<\/h3>/
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
it "doesn't produce an HTML document" do
|
33
|
+
@output.wont_match /^<!doctype html>/
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
37
|
+
describe 'with rendering with layouts' do
|
38
|
+
before do
|
39
|
+
@output = Styledown.render(@data, 'buttons.md', layout: '<!doctype html><%- body %>')
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
it "includes the head text" do
|
46
|
-
@output.must_match /<meta>/
|
47
|
-
end
|
42
|
+
it 'produces HTML' do
|
43
|
+
@output.must_match /<h3[^>]+>hi<\/h3>/
|
44
|
+
end
|
48
45
|
|
49
|
-
|
50
|
-
|
46
|
+
it "uses the layout" do
|
47
|
+
@output.must_match /^<!doctype html>/
|
48
|
+
end
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
54
52
|
describe 'Working with arrays of strings' do
|
55
53
|
before do
|
56
|
-
@output = Styledown.
|
57
|
-
fixture_path('simple/sample.
|
58
|
-
fixture_path('simple/
|
54
|
+
@output = Styledown.parse_files([
|
55
|
+
fixture_path('simple/sample.md'),
|
56
|
+
fixture_path('simple/other_sample.md')
|
59
57
|
])
|
60
58
|
end
|
61
59
|
|
62
|
-
it '
|
63
|
-
@output.
|
64
|
-
|
65
|
-
|
66
|
-
it 'renders from .css' do
|
67
|
-
@output.must_match /Sample CSS block<\/h3>/
|
60
|
+
it 'parses' do
|
61
|
+
@output['files'].must_be_kind_of Hash
|
62
|
+
@output['files'][fixture_path('simple/sample.md')].must_be_kind_of Hash
|
63
|
+
@output['files'][fixture_path('simple/other_sample.md')].must_be_kind_of Hash
|
68
64
|
end
|
69
65
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,17 +4,17 @@ require './lib/styledown'
|
|
4
4
|
begin
|
5
5
|
require 'minitest/reporters'
|
6
6
|
if ENV['reporter'] == 'spec'
|
7
|
-
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new(:
|
7
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new(color: true)
|
8
8
|
else
|
9
9
|
Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
|
10
10
|
end
|
11
11
|
rescue LoadError => e
|
12
12
|
end
|
13
13
|
|
14
|
-
def test_path(path='')
|
14
|
+
def test_path(path = '')
|
15
15
|
File.expand_path("../#{path}", __FILE__)
|
16
16
|
end
|
17
17
|
|
18
|
-
def fixture_path(path='')
|
18
|
+
def fixture_path(path = '')
|
19
19
|
test_path "fixtures/#{path}"
|
20
20
|
end
|