tdiary-style-markdown 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1dd6d50264ec4bae6f8952ca1bf62a071380fb5
4
- data.tar.gz: 339b726f102c29bc76ba190ef06bac67a839032c
3
+ metadata.gz: b824c99bcc7050d699d17c4e8812cd3488555683
4
+ data.tar.gz: 49ecbb1e5c0dbf016d5a619b74f53724ab25bea9
5
5
  SHA512:
6
- metadata.gz: d8886a36942948a6f4dff4b48aa2c1ba508491db32c7f13bc3accef3ad8d3870b4f124068ecfc6c751562c63da45177757ddd484dcdfe67698e5629086fb6894
7
- data.tar.gz: 3310cb79e338d525af5642e43d6fdb6f11a2fd44dc8344c8407edef95fc16fffd1e33f41f42dbb43d762e368048e0849b957539de7849fda852d111fd67328d1
6
+ metadata.gz: 66f698b1cb223940d81722c3ba26672ae30798231b8ce6e3dfc0f39cb2a227eea01cb17206e0cc6553b09a0c0a585cce9d99c7a94f19d40c12c2ccafb46f630e
7
+ data.tar.gz: 11665f3157974f4c4f6bceb867f72664863b4e5e917efe27f856f409a2cfee629e88a70dac703f4e4c6217eb6df2bbfc28551ae5d8c7f9dfcfbc1294ec31e8b3
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ cache: bundler
3
+
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  This is based on tdiary-style-gfm gem.
6
6
 
7
+ [![Build Status](https://travis-ci.org/clear-code/tdiary-style-markdown.svg?branch=master)](https://travis-ci.org/clear-code/tdiary-style-markdown)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
+ task :default => :test
2
+
1
3
  require "bundler/gem_tasks"
4
+
5
+ desc "Run tests"
6
+ task :test do
7
+ ruby("test/run-test.rb")
8
+ end
@@ -198,6 +198,11 @@ module TDiary
198
198
  else
199
199
  nil
200
200
  end
201
+ caption_part = ""
202
+ language, caption = language.split(":", 2) if language
203
+ if caption
204
+ caption_part = "<span class=\"caption\">#{escape_html(caption)}</span>\n"
205
+ end
201
206
  code = node.string_content
202
207
  lexer = Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText
203
208
  formatter = rouge_formatter(lexer)
@@ -208,7 +213,7 @@ module TDiary
208
213
  if language
209
214
  out(' lang="', language, '"')
210
215
  end
211
- out('><code>')
216
+ out(">")
212
217
  else
213
218
  out("<pre#{sourcepos(node)}")
214
219
  if language
@@ -217,6 +222,7 @@ module TDiary
217
222
  out(' class="highlight plaintext">')
218
223
  end
219
224
  end
225
+ out(caption_part)
220
226
  out('<code>')
221
227
  out(highlighted)
222
228
  out('</code></pre>')
@@ -1,7 +1,7 @@
1
1
  module TDiary
2
2
  module Style
3
3
  module Markdown
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
6
6
  end
7
7
  end
@@ -518,4 +518,62 @@ HTML<%=fn %Q(Hyper Text Markup Language)%> is a markup language<%=fn %Q(<a href=
518
518
 
519
519
  assert_equal(@html, @diary.to_html)
520
520
  end
521
+
522
+ class QiitaStyleCodeBlock < self
523
+ def test_caption
524
+ source = <<-EOF
525
+ # Code Blocks
526
+
527
+ ```plaintext:example1.rb
528
+ p "OK"
529
+ ```
530
+
531
+ ~~~plaintext:example2.rb
532
+ p "OK"
533
+ ~~~
534
+ EOF
535
+ @diary.append(source)
536
+
537
+ @html = <<-EOF
538
+ <div class="section">
539
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
540
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "Code Blocks" ) %></h3>
541
+ <pre class="highlight plaintext"><span class="caption">example1.rb</span>
542
+ <code>p "OK"
543
+ </code></pre>
544
+ <pre class="highlight plaintext"><span class="caption">example2.rb</span>
545
+ <code>p "OK"
546
+ </code></pre>
547
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
548
+ </div>
549
+ EOF
550
+
551
+ assert_equal(@html, @diary.to_html)
552
+ end
553
+
554
+ def test_caption_with_tilde
555
+ source = <<-EOF
556
+ # Code Blocks
557
+
558
+ ```plaintext:~/example1.rb
559
+ p "OK"
560
+ ```
561
+ EOF
562
+ @diary.append(source)
563
+ # note: tilde after three-tilde code fence is not supported by cmark...
564
+
565
+ @html = <<-EOF
566
+ <div class="section">
567
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
568
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "Code Blocks" ) %></h3>
569
+ <pre class="highlight plaintext"><span class="caption">~/example1.rb</span>
570
+ <code>p "OK"
571
+ </code></pre>
572
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
573
+ </div>
574
+ EOF
575
+
576
+ assert_equal(@html, @diary.to_html)
577
+ end
578
+ end
521
579
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-style-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Okimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
+ - ".travis.yml"
119
120
  - Gemfile
120
121
  - LICENSE
121
122
  - README.md