rubydown 0.1.0 → 0.2.0
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
- data/.circleci/config.yml +4 -4
- data/README.md +2 -3
- data/appveyor.yml +2 -2
- data/exe/rubydown +12 -1
- data/lib/rubydown.rb +24 -10
- data/lib/rubydown/version.rb +1 -1
- data/rubydown.gemspec +4 -2
- data/templates/template.html.erb +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce37172e6c98263b0b2c9bbdb3df5d695342183756af350fc6460619fcc11602
|
4
|
+
data.tar.gz: 2242d204fec921ef8a3b5c782a28dcf1eaa3d3a9f835218bf5830449fb3f6cfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6354f30245f6e34a1a0eb4a9bf5d26383dac2590455bbbb40ab6c51fbf516a132637d9a913e03763159916b2d9492fa746d2c0b61e75b48815b391ea3a56084e
|
7
|
+
data.tar.gz: 1ad1c76f3200793b6d5c094d6f93968a1078440174bcdabaf5ab8ddc85eb5e56e99c0477de480b648604c76009c5029a0be5d1744e7e5cf84fa3d551ecbc8849
|
data/.circleci/config.yml
CHANGED
@@ -7,7 +7,7 @@ jobs:
|
|
7
7
|
build:
|
8
8
|
docker:
|
9
9
|
- image: ruby
|
10
|
-
|
10
|
+
|
11
11
|
working_directory: ~/repo
|
12
12
|
|
13
13
|
steps:
|
@@ -19,9 +19,9 @@ jobs:
|
|
19
19
|
apt-get update
|
20
20
|
apt-get install -y gnuplot
|
21
21
|
gem build rubydown.gemspec
|
22
|
-
gem install rubydown-0.
|
22
|
+
gem install rubydown-0.2.0.gem
|
23
23
|
gem install bio
|
24
|
-
|
24
|
+
|
25
25
|
# run tests!
|
26
26
|
- run:
|
27
27
|
name: run tests
|
@@ -29,7 +29,7 @@ jobs:
|
|
29
29
|
rubydown -i examples/bio.md -e templates/template.html.erb -o /tmp/bio.html
|
30
30
|
rubydown -i examples/table.md -e templates/template.html.erb -o /tmp/table.html
|
31
31
|
rubydown -i examples/graph.md -e templates/template.html.erb -o /tmp/graph.html
|
32
|
-
|
32
|
+
|
33
33
|
# collect reports
|
34
34
|
- store_artifacts:
|
35
35
|
path: /tmp
|
data/README.md
CHANGED
@@ -18,8 +18,7 @@ https://github.com/pystitch/stitch
|
|
18
18
|
|
19
19
|
```
|
20
20
|
apt install gnuplot # When you use numo-gnuplot in your workflow markdown
|
21
|
-
gem install
|
22
|
-
gem specific_install https://github.com/sciruby-jp/rubydown
|
21
|
+
gem install rubydown
|
23
22
|
```
|
24
23
|
|
25
24
|
## Usage (example with [rumale](https://github.com/yoshoku/rumale) and [rdatasets](https://github.com/kojix2/rdatasets))
|
@@ -28,5 +27,5 @@ gem specific_install https://github.com/sciruby-jp/rubydown
|
|
28
27
|
gem install rumale rdatasets
|
29
28
|
git clone git://github.com/sciruby-jp/rubydown
|
30
29
|
cd rubydown/examples
|
31
|
-
rubydown -i rumale.md
|
30
|
+
rubydown -i rumale.md
|
32
31
|
```
|
data/appveyor.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
install:
|
3
3
|
- set PATH=C:\Ruby25-x64\bin;%PATH%
|
4
4
|
- gem build rubydown.gemspec
|
5
|
-
- gem install rubydown-0.
|
5
|
+
- gem install rubydown-0.2.0.gem
|
6
6
|
|
7
7
|
build: off
|
8
8
|
|
@@ -20,6 +20,6 @@ test_script:
|
|
20
20
|
- rubydown -i examples\bio.md -e templates\template.html.erb -o bio.html
|
21
21
|
- rubydown -i examples\graph.md -e templates\template.html.erb -o graph.html
|
22
22
|
- rubydown -i examples\table.md -e templates\template.html.erb -o table.html
|
23
|
-
|
23
|
+
|
24
24
|
artifacts:
|
25
25
|
- path: '*.html'
|
data/exe/rubydown
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'kramdown'
|
4
4
|
require 'erb'
|
5
5
|
require 'stringio'
|
6
|
-
|
6
|
+
require 'base64'
|
7
7
|
require 'optparse'
|
8
8
|
|
9
9
|
require 'rubydown'
|
@@ -14,16 +14,23 @@ end
|
|
14
14
|
|
15
15
|
class EvalDoc < Kramdown::Document
|
16
16
|
attr_accessor :context, :stdout
|
17
|
+
attr_reader :javascripts
|
17
18
|
|
18
19
|
def initialize(text, *opts)
|
19
20
|
super(text, *opts)
|
20
21
|
|
22
|
+
@javascripts = {}
|
21
23
|
self.context = get_context
|
22
24
|
self.root = scan_el(self.root)
|
23
25
|
end
|
24
26
|
|
27
|
+
REQUIREJS_SCRIPT_TAG = '<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>'
|
28
|
+
MATHJAX_SCRIPT_TAG = "<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>"
|
29
|
+
|
25
30
|
private
|
26
31
|
def scan_el(el)
|
32
|
+
@javascripts[:mathjax] ||= MATHJAX_SCRIPT_TAG if el.type == :math
|
33
|
+
|
27
34
|
new_children = []
|
28
35
|
el.children.each do |child_el|
|
29
36
|
child_el = scan_el(child_el)
|
@@ -34,6 +41,7 @@ class EvalDoc < Kramdown::Document
|
|
34
41
|
if is_code && child_el.options[:lang] == 'ruby'
|
35
42
|
code = child_el.value.gsub(/^ *ruby *\n/, '')
|
36
43
|
new_children << eval_and_elementize(code)
|
44
|
+
@javascripts[:requirejs] ||= REQUIREJS_SCRIPT_TAG
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
@@ -54,6 +62,9 @@ class EvalDoc < Kramdown::Document
|
|
54
62
|
case
|
55
63
|
when eval_result.respond_to?(:to_html)
|
56
64
|
Kramdown::Document.new(eval_result.to_html, input: :html).root
|
65
|
+
when eval_result.instance_of?(File) && File.extname(eval_result.path) == ".png"
|
66
|
+
img_b64 = Base64.encode64(File.binread(eval_result.path))
|
67
|
+
Kramdown::Document.new("<img src='data:image/png;base64,#{img_b64}' />", input: :html).root
|
57
68
|
else
|
58
69
|
text_result_el(stdout_string + "=> #{eval_result}")
|
59
70
|
end
|
data/lib/rubydown.rb
CHANGED
@@ -5,27 +5,41 @@ require 'rbplotly'
|
|
5
5
|
require 'numo/gnuplot'
|
6
6
|
require 'base64'
|
7
7
|
require 'tempfile'
|
8
|
+
require 'charty'
|
8
9
|
|
9
10
|
|
10
11
|
class Numo::NArray
|
11
12
|
def to_html
|
12
|
-
|
13
|
-
|
13
|
+
case ndim
|
14
|
+
when 2
|
15
|
+
rows = self.to_a.map do |row|
|
16
|
+
elems = row.map do |elem|
|
17
|
+
"<td>#{elem}</td>"
|
18
|
+
end
|
19
|
+
"<tr>#{elems.join}</tr>"
|
20
|
+
end
|
21
|
+
"<table>#{rows.join}</table>"
|
22
|
+
when 1
|
23
|
+
cols = self.to_a.map do |elem|
|
14
24
|
"<td>#{elem}</td>"
|
15
25
|
end
|
16
|
-
"<tr>#{
|
26
|
+
"<table><tr>#{cols.join}</tr></table>"
|
27
|
+
else
|
28
|
+
inspect
|
17
29
|
end
|
18
|
-
"<table>#{rows.join}</table>"
|
19
30
|
end
|
20
31
|
end
|
21
32
|
|
22
|
-
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
Charty::RenderContext.prepend Module.new {
|
34
|
+
def render(filename=nil)
|
35
|
+
super
|
36
|
+
if filename.nil?
|
37
|
+
p "The image could not be rendered. In the environment without IRuby, the file name for the charty render method is required."
|
38
|
+
else
|
39
|
+
File.open(filename)
|
40
|
+
end
|
27
41
|
end
|
28
|
-
|
42
|
+
}
|
29
43
|
|
30
44
|
module Rubydown
|
31
45
|
class RbMarkPlot < Numo::Gnuplot
|
data/lib/rubydown/version.rb
CHANGED
data/rubydown.gemspec
CHANGED
@@ -6,8 +6,8 @@ require "rubydown/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "rubydown"
|
8
8
|
spec.version = Rubydown::VERSION
|
9
|
-
spec.authors = ["Kozo Nishida"]
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Yusuke Sangenya", "Kozo Nishida", "Kazuhiro Nishiyama"]
|
10
|
+
spec.email = ["kozo.nishida@gmail.com"]
|
11
11
|
spec.license = 'MIT'
|
12
12
|
spec.summary = "Pure Ruby R Markdown clone."
|
13
13
|
spec.description = "rubydown is R Markdown clone for Rubyists."
|
@@ -40,6 +40,8 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_dependency "numo-narray", "~> 0.9.1"
|
41
41
|
spec.add_dependency "numo-gnuplot", "~> 0.2.4"
|
42
42
|
spec.add_dependency "rbplotly", "~> 0.1.2"
|
43
|
+
spec.add_dependency "charty", "0.1.2.dev"
|
44
|
+
spec.add_dependency "matplotlib", "~> 1.0.0"
|
43
45
|
|
44
46
|
spec.add_development_dependency "bundler", "~> 1.17"
|
45
47
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/templates/template.html.erb
CHANGED
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubydown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Yusuke Sangenya
|
7
8
|
- Kozo Nishida
|
9
|
+
- Kazuhiro Nishiyama
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2019-
|
13
|
+
date: 2019-04-17 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: kramdown
|
@@ -80,6 +82,34 @@ dependencies:
|
|
80
82
|
- - "~>"
|
81
83
|
- !ruby/object:Gem::Version
|
82
84
|
version: 0.1.2
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: charty
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.1.2.dev
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.1.2.dev
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: matplotlib
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.0.0
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.0.0
|
83
113
|
- !ruby/object:Gem::Dependency
|
84
114
|
name: bundler
|
85
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +154,7 @@ dependencies:
|
|
124
154
|
version: '3.3'
|
125
155
|
description: rubydown is R Markdown clone for Rubyists.
|
126
156
|
email:
|
127
|
-
-
|
157
|
+
- kozo.nishida@gmail.com
|
128
158
|
executables:
|
129
159
|
- rubydown
|
130
160
|
extensions: []
|