tdiary-style-markdown 0.4.0 → 0.5.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/lib/tdiary/style/markdown.rb +47 -31
- data/lib/tdiary/style/markdown/version.rb +1 -1
- data/tdiaty-style-markdown.gemspec +1 -1
- data/test/tdiary/style/markdown-test.rb +2 -16
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1dd6d50264ec4bae6f8952ca1bf62a071380fb5
|
4
|
+
data.tar.gz: 339b726f102c29bc76ba190ef06bac67a839032c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8886a36942948a6f4dff4b48aa2c1ba508491db32c7f13bc3accef3ad8d3870b4f124068ecfc6c751562c63da45177757ddd484dcdfe67698e5629086fb6894
|
7
|
+
data.tar.gz: 3310cb79e338d525af5642e43d6fdb6f11a2fd44dc8344c8407edef95fc16fffd1e33f41f42dbb43d762e368048e0849b957539de7849fda852d111fd67328d1
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'commonmarker'
|
2
2
|
require 'rouge'
|
3
|
-
require 'rouge/plugins/redcarpet'
|
4
3
|
require 'twitter-text'
|
5
4
|
|
6
5
|
module TDiary
|
@@ -62,12 +61,10 @@ module TDiary
|
|
62
61
|
end
|
63
62
|
|
64
63
|
# 2. Apply markdown conversion
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
footnotes: true)
|
70
|
-
r = renderer.render(r)
|
64
|
+
extensions = [:autolink, :table]
|
65
|
+
renderer = HTMLwithRouge.new(extensions: extensions)
|
66
|
+
doc = CommonMarker.render_doc(r, :DEFAULT, extensions)
|
67
|
+
r = renderer.render(doc)
|
71
68
|
|
72
69
|
# 3. Stash <pre> and <code> tags
|
73
70
|
pre_tag_stashes = []
|
@@ -125,13 +122,6 @@ module TDiary
|
|
125
122
|
end
|
126
123
|
end
|
127
124
|
|
128
|
-
footnote_stashes = HTMLwithRouge.tdiary_style_markdown_footnote_stashes
|
129
|
-
footnote_stashes.each do |num, raw_content|
|
130
|
-
if r["@@tdiary-style-markdown-footnote-#{num}@@"]
|
131
|
-
r["@@tdiary-style-markdown-footnote-#{num}@@"] = raw_content
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
125
|
r
|
136
126
|
end
|
137
127
|
|
@@ -200,26 +190,52 @@ module TDiary
|
|
200
190
|
end
|
201
191
|
end
|
202
192
|
|
203
|
-
class HTMLwithRouge <
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
193
|
+
class HTMLwithRouge < CommonMarker::HtmlRenderer
|
194
|
+
|
195
|
+
def code_block(node)
|
196
|
+
language = if node.fence_info && !node.fence_info.empty?
|
197
|
+
node.fence_info.split(/\s+/)[0]
|
198
|
+
else
|
199
|
+
nil
|
200
|
+
end
|
201
|
+
code = node.string_content
|
202
|
+
lexer = Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText
|
203
|
+
formatter = rouge_formatter(lexer)
|
204
|
+
highlighted = formatter.format(lexer.lex(code))
|
205
|
+
block do
|
206
|
+
if option_enabled?(:GITHUB_PRE_LANG)
|
207
|
+
out("<pre#{sourcepos(node)}")
|
208
|
+
if language
|
209
|
+
out(' lang="', language, '"')
|
210
|
+
end
|
211
|
+
out('><code>')
|
212
|
+
else
|
213
|
+
out("<pre#{sourcepos(node)}")
|
214
|
+
if language
|
215
|
+
out(' class="highlight ', language, '">')
|
216
|
+
else
|
217
|
+
out(' class="highlight plaintext">')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
out('<code>')
|
221
|
+
out(highlighted)
|
222
|
+
out('</code></pre>')
|
223
|
+
end
|
213
224
|
end
|
214
225
|
|
215
|
-
def
|
216
|
-
|
217
|
-
|
218
|
-
|
226
|
+
def image(node)
|
227
|
+
out('<img src="', escape_href(node.url), '"')
|
228
|
+
plain do
|
229
|
+
out(' alt="', :children, '"')
|
230
|
+
end
|
231
|
+
if node.title && !node.title.empty?
|
232
|
+
out(' title="', escape_html(node.title), '"')
|
233
|
+
end
|
234
|
+
out('>')
|
219
235
|
end
|
220
236
|
|
221
|
-
def
|
222
|
-
"
|
237
|
+
def rouge_formatter(lexer)
|
238
|
+
::Rouge::Formatters::HTML.new(:css_class => "highlight #{lexer.tag}")
|
223
239
|
end
|
224
240
|
end
|
225
241
|
end
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'commonmarker'
|
22
22
|
spec.add_dependency 'rouge'
|
23
23
|
spec.add_dependency 'twitter-text'
|
24
24
|
spec.add_dependency 'gemoji'
|
@@ -29,9 +29,7 @@ honbun
|
|
29
29
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
30
30
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
31
31
|
<p>honbun</p>
|
32
|
-
|
33
32
|
<h4>subTitleH4</h4>
|
34
|
-
|
35
33
|
<p>honbun</p>
|
36
34
|
<pre class="highlight plaintext"><code># comment in code block
|
37
35
|
</code></pre>
|
@@ -76,9 +74,7 @@ replace
|
|
76
74
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
77
75
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "replaceTitle" ) %></h3>
|
78
76
|
<p>replace</p>
|
79
|
-
|
80
77
|
<h4>replaceTitleH4</h4>
|
81
|
-
|
82
78
|
<p>replace</p>
|
83
79
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
84
80
|
</div>
|
@@ -105,9 +101,7 @@ http://www.google.com
|
|
105
101
|
<ul>
|
106
102
|
<li><a href="http://www.google.com">http://www.google.com</a></li>
|
107
103
|
</ul>
|
108
|
-
|
109
104
|
<p><a href="https://www.google.com">google</a></p>
|
110
|
-
|
111
105
|
<p><a href="http://www.google.com">http://www.google.com</a></p>
|
112
106
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
113
107
|
</div>
|
@@ -129,7 +123,6 @@ http://www.google.com
|
|
129
123
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
130
124
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
131
125
|
<p><img src="http://www.google.com/logo.jpg" alt=""></p>
|
132
|
-
|
133
126
|
<p><img src="http://www.google.com/logo.jpg" alt="google"></p>
|
134
127
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
135
128
|
</div>
|
@@ -174,7 +167,6 @@ http://example.com is example.com
|
|
174
167
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
175
168
|
<pre class="highlight ruby"><code><span class="vi">@foo</span>
|
176
169
|
</code></pre>
|
177
|
-
|
178
170
|
<p><a href="http://example.com">http://example.com</a> is example.com</p>
|
179
171
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
180
172
|
</div>
|
@@ -217,7 +209,6 @@ http://example.com is example.com
|
|
217
209
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
218
210
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
219
211
|
<p><%=plugin 'val'%></p>
|
220
|
-
|
221
212
|
<p><%=plugin "val", 'val'%></p>
|
222
213
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
223
214
|
</div>
|
@@ -260,7 +251,6 @@ http://example.com is example.com
|
|
260
251
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
261
252
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
262
253
|
<p><%=my "20120101p01", "20120101p01" %></p>
|
263
|
-
|
264
254
|
<p><%=my "20120101p01", "Link" %></p>
|
265
255
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
266
256
|
</div>
|
@@ -332,7 +322,6 @@ p :some_code
|
|
332
322
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
333
323
|
<pre class="highlight ruby"><code><span class="nb">p</span> <span class="ss">:some_code</span>
|
334
324
|
</code></pre>
|
335
|
-
|
336
325
|
<p>@a_matsuda is amatsuda</p>
|
337
326
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
338
327
|
</div>
|
@@ -355,7 +344,6 @@ p :some_code
|
|
355
344
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
356
345
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
357
346
|
<p><code>:some_code</code></p>
|
358
|
-
|
359
347
|
<p>@a_matsuda is amatsuda</p>
|
360
348
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
361
349
|
</div>
|
@@ -377,7 +365,7 @@ p :some_code
|
|
377
365
|
<div class="section">
|
378
366
|
<%=section_enter_proc( Time.at( 1041346800 ) )%>
|
379
367
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
380
|
-
<p><img src='
|
368
|
+
<p><img src='//www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/sushi.png' width='20' height='20' title='sushi' alt='sushi' class='emoji' /> は美味しい</p>
|
381
369
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
382
370
|
</div>
|
383
371
|
EOF
|
@@ -467,9 +455,7 @@ ruby -e "puts \"hello, world.\""
|
|
467
455
|
<h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
|
468
456
|
<pre class="highlight plaintext"><code>ruby -e "puts \"hello, world.\""
|
469
457
|
</code></pre>
|
470
|
-
|
471
458
|
<p><code>ruby -e "puts \"hello, world.\""</code></p>
|
472
|
-
|
473
459
|
<p><%=plugin "\0", "\1", "\2"%></p>
|
474
460
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
475
461
|
</div>
|
@@ -498,7 +484,6 @@ NOTE: `{{.NetworkSettings.IPAddress}}` is golang template.
|
|
498
484
|
<p>Get IP Address of Docker Container:</p>
|
499
485
|
<pre class="highlight plaintext"><code>% docker inspect -f "{{.NetworkSettings.IPAddress}} {{.Config.Hostname}} # Name:{{.Name}}" `docker ps -q`
|
500
486
|
</code></pre>
|
501
|
-
|
502
487
|
<p>NOTE: <code>{{.NetworkSettings.IPAddress}}</code> is golang template.</p>
|
503
488
|
<%=section_leave_proc( Time.at( 1041346800 ) )%>
|
504
489
|
</div>
|
@@ -507,6 +492,7 @@ NOTE: `{{.NetworkSettings.IPAddress}}` is golang template.
|
|
507
492
|
end
|
508
493
|
|
509
494
|
def test_footnote
|
495
|
+
pend("footnote is unsupported for now.")
|
510
496
|
source = <<-'EOF'
|
511
497
|
# subTitle
|
512
498
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdiary-style-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Okimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: commonmarker
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.6.11
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Markdown Style for tDiary
|