markdown_views 3.4.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06487fe4e723f10bed4f034f24a63f12c273498f05a41fa0003622b66dce284c'
4
- data.tar.gz: 1f0ad5c2a6d30cd968a21b635ae27a80999d2d03d53f393bccba9441e315c6df
3
+ metadata.gz: 91b84a7ec0592a3a41061db057e8abfe3f549b39c5e5dc0a52af6a2559f14465
4
+ data.tar.gz: 481980a8af3e86703ba67ebcf89e6993c3067e76771e99385e514a4f02d55f99
5
5
  SHA512:
6
- metadata.gz: 83a114cad038fa5e4a88597ac8fbffb391f0d874cd2296c41c9edf290e11416d38b55a5ae35c3e62c9a3cd8df641f77ce3e63682416def3f4de26e31d02cbc17
7
- data.tar.gz: 688786a5764b6d16fdfd1a6d66d38d8a600ae41a8ce8c1fdf6c137d27f9f4eda29ea849527f107da928a28e79b9d168f74952d4ba30f6e94a92b168bc3a9609b
6
+ metadata.gz: 9c57762ed95990edfe704c926687cae2c00c56194f8c484481fdeb631e88a254d02f21a96be82d786e968e9864b442c8b49b4f9d33c91c4620c36de36aa1a020
7
+ data.tar.gz: 0e80e781992c434a15879eaf47f1ff99784e3214ee88587d358d2bbf3766728dc3dcedc4746c36114dcbb80600564e78cdd09be8e5e73c3d2a11efbea57d4011
data/README.md CHANGED
@@ -70,14 +70,10 @@ See `app/assets/stylesheets/` for the complete list.
70
70
 
71
71
  ## Installation
72
72
 
73
- Add this line to your application's Gemfile:
73
+ Add to Gemfile:
74
74
 
75
75
  gem 'markdown_views'
76
76
 
77
- And then execute:
78
-
79
- $ bundle
80
-
81
77
 
82
78
  ## Gem versions
83
79
 
@@ -95,13 +91,27 @@ The stylesheets were refreshed from Rouge 4.4 which corrects a few missing CSS s
95
91
 
96
92
  ## Contributing
97
93
 
98
- 1. Fork it ( http://github.com/zarqman/markdown_views/fork )
99
- 2. Create your feature branch (`git checkout -b my-new-feature`)
100
- 3. Commit your changes (`git commit -am 'Add some feature'`)
101
- 4. Push to the branch (`git push origin my-new-feature`)
102
- 5. Create new Pull Request
94
+ Contributions are welcomed. If unsure about the scope or reach of a potential PR, feel free to open a discussion Issue first (not required though).
95
+
96
+ Please submit human-written contributions only. No contributions containing output generated by LLMs or other non-deterministic systems are allowed.
97
+
98
+ * Code, tests, docs, PRs: must be 100% human written.
99
+ * Issues, security reports: must originally be 100% human written. If not originally in English, an LLM may be used to translate to English provided that this translation is disclosed.
100
+
101
+ We recognize that opinions about the use of LLMs and non-deterministic systems vary widely. Still, we respectfully ask that you honor this policy when interacting with this project.
102
+
103
+ ###### Q: May I use LLMs apart from contributions?
104
+ All usage, training or otherwise, must respect copyrights. Beyond that, we've found that LLMs are prone to errors and misunderstandings--sometimes obvious, sometimes subtle. Please verify everything before trusting an LLM's output.
105
+
106
+
107
+ #### Running tests
108
+
109
+ ```
110
+ bundle install
111
+ rake [test]
112
+ ```
103
113
 
104
114
 
105
115
  ## License
106
116
 
107
- MIT
117
+ [MIT](LICENSE.txt)
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
2
+ load "rails/tasks/engine.rake"
3
+
1
4
  require "bundler/gem_tasks"
2
5
  require "rake/testtask"
3
6
 
7
+ desc 'regenerate stylesheets for rouge themes'
4
8
  task :generate_stylesheets do
5
9
  %w( base16.dark base16.light base16.monokai.dark base16.monokai.light
6
10
  base16.solarized.dark base16.solarized.light bw colorful
@@ -10,10 +10,19 @@ module MarkdownViews
10
10
  R1
11
11
  end
12
12
 
13
- def preprocessor
14
- @@preprocessor ||= begin
15
- pp = MarkdownViews.preprocessor || :raw
16
- ActionView::Template.registered_template_handler(pp) || raise('Unknown template handler')
13
+ if ActionView::Template::Handlers.respond_to?(:template_handlers) # as of rails 8.2
14
+ def preprocessor
15
+ @@preprocessor ||= begin
16
+ pp = MarkdownViews.preprocessor || :raw
17
+ ActionView::Template::Handlers.template_handlers[pp.to_sym] || raise('Unknown template handler')
18
+ end
19
+ end
20
+ else
21
+ def preprocessor
22
+ @@preprocessor ||= begin
23
+ pp = MarkdownViews.preprocessor || :raw
24
+ ActionView::Template.registered_template_handler(pp) || raise('Unknown template handler')
25
+ end
17
26
  end
18
27
  end
19
28
 
@@ -1,3 +1,3 @@
1
1
  module MarkdownViews
2
- VERSION = '3.4.0'
2
+ VERSION = '3.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
@@ -113,9 +113,6 @@ executables: []
113
113
  extensions: []
114
114
  extra_rdoc_files: []
115
115
  files:
116
- - ".gitignore"
117
- - Gemfile
118
- - Gemfile.lock
119
116
  - LICENSE.txt
120
117
  - README.md
121
118
  - Rakefile
@@ -146,15 +143,13 @@ files:
146
143
  - lib/markdown_views/handler.rb
147
144
  - lib/markdown_views/renderer.rb
148
145
  - lib/markdown_views/version.rb
149
- - markdown_views.gemspec
150
- - test/config_test.rb
151
- - test/render_test.rb
152
- - test/strip_comments_test.rb
153
- - test/test_helper.rb
154
146
  homepage: https://github.com/zarqman/markdown_views
155
147
  licenses:
156
148
  - MIT
157
- metadata: {}
149
+ metadata:
150
+ homepage_uri: https://github.com/zarqman/markdown_views
151
+ source_code_uri: https://github.com/zarqman/markdown_views
152
+ changelog_uri: https://github.com/zarqman/markdown_views/blob/master/CHANGELOG.md
158
153
  rdoc_options: []
159
154
  require_paths:
160
155
  - lib
@@ -169,11 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
164
  - !ruby/object:Gem::Version
170
165
  version: '0'
171
166
  requirements: []
172
- rubygems_version: 3.6.9
167
+ rubygems_version: 4.0.16
173
168
  specification_version: 4
174
169
  summary: Add .md template handler to Rails.
175
- test_files:
176
- - test/config_test.rb
177
- - test/render_test.rb
178
- - test/strip_comments_test.rb
179
- - test/test_helper.rb
170
+ test_files: []
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .ruby-*
6
- .yardoc
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in markdown_views.gemspec
4
- gemspec
5
-
6
- gem 'minitest', '~> 6'
data/Gemfile.lock DELETED
@@ -1,237 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- markdown_views (3.4.0)
5
- commonmarker (>= 1.1, < 3.0)
6
- rails (>= 6.1)
7
- rouge (>= 4, < 6)
8
- securerandom
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- action_text-trix (2.1.19)
14
- railties
15
- actioncable (8.1.3)
16
- actionpack (= 8.1.3)
17
- activesupport (= 8.1.3)
18
- nio4r (~> 2.0)
19
- websocket-driver (>= 0.6.1)
20
- zeitwerk (~> 2.6)
21
- actionmailbox (8.1.3)
22
- actionpack (= 8.1.3)
23
- activejob (= 8.1.3)
24
- activerecord (= 8.1.3)
25
- activestorage (= 8.1.3)
26
- activesupport (= 8.1.3)
27
- mail (>= 2.8.0)
28
- actionmailer (8.1.3)
29
- actionpack (= 8.1.3)
30
- actionview (= 8.1.3)
31
- activejob (= 8.1.3)
32
- activesupport (= 8.1.3)
33
- mail (>= 2.8.0)
34
- rails-dom-testing (~> 2.2)
35
- actionpack (8.1.3)
36
- actionview (= 8.1.3)
37
- activesupport (= 8.1.3)
38
- nokogiri (>= 1.8.5)
39
- rack (>= 2.2.4)
40
- rack-session (>= 1.0.1)
41
- rack-test (>= 0.6.3)
42
- rails-dom-testing (~> 2.2)
43
- rails-html-sanitizer (~> 1.6)
44
- useragent (~> 0.16)
45
- actiontext (8.1.3)
46
- action_text-trix (~> 2.1.15)
47
- actionpack (= 8.1.3)
48
- activerecord (= 8.1.3)
49
- activestorage (= 8.1.3)
50
- activesupport (= 8.1.3)
51
- globalid (>= 0.6.0)
52
- nokogiri (>= 1.8.5)
53
- actionview (8.1.3)
54
- activesupport (= 8.1.3)
55
- builder (~> 3.1)
56
- erubi (~> 1.11)
57
- rails-dom-testing (~> 2.2)
58
- rails-html-sanitizer (~> 1.6)
59
- activejob (8.1.3)
60
- activesupport (= 8.1.3)
61
- globalid (>= 0.3.6)
62
- activemodel (8.1.3)
63
- activesupport (= 8.1.3)
64
- activerecord (8.1.3)
65
- activemodel (= 8.1.3)
66
- activesupport (= 8.1.3)
67
- timeout (>= 0.4.0)
68
- activestorage (8.1.3)
69
- actionpack (= 8.1.3)
70
- activejob (= 8.1.3)
71
- activerecord (= 8.1.3)
72
- activesupport (= 8.1.3)
73
- marcel (~> 1.0)
74
- activesupport (8.1.3)
75
- base64
76
- bigdecimal
77
- concurrent-ruby (~> 1.0, >= 1.3.1)
78
- connection_pool (>= 2.2.5)
79
- drb
80
- i18n (>= 1.6, < 2)
81
- json
82
- logger (>= 1.4.2)
83
- minitest (>= 5.1)
84
- securerandom (>= 0.3)
85
- tzinfo (~> 2.0, >= 2.0.5)
86
- uri (>= 0.13.1)
87
- ansi (1.6.0)
88
- base64 (0.3.0)
89
- bigdecimal (4.1.2)
90
- builder (3.3.0)
91
- commonmarker (2.9.0-aarch64-linux)
92
- commonmarker (2.9.0-arm64-darwin)
93
- commonmarker (2.9.0-x86_64-darwin)
94
- commonmarker (2.9.0-x86_64-linux)
95
- concurrent-ruby (1.3.7)
96
- connection_pool (3.0.2)
97
- crass (1.0.7)
98
- date (3.5.1)
99
- drb (2.2.3)
100
- erb (6.0.4)
101
- erubi (1.13.1)
102
- globalid (1.4.0)
103
- activesupport (>= 6.1)
104
- i18n (1.15.2)
105
- concurrent-ruby (~> 1.0)
106
- io-console (0.8.2)
107
- irb (1.18.0)
108
- pp (>= 0.6.0)
109
- prism (>= 1.3.0)
110
- rdoc (>= 4.0.0)
111
- reline (>= 0.4.2)
112
- json (2.21.1)
113
- logger (1.7.0)
114
- loofah (2.25.1)
115
- crass (~> 1.0.2)
116
- nokogiri (>= 1.12.0)
117
- mail (2.9.1)
118
- logger
119
- mini_mime (>= 0.1.1)
120
- net-imap
121
- net-pop
122
- net-smtp
123
- marcel (1.2.1)
124
- mini_mime (1.1.5)
125
- minitest (6.0.6)
126
- drb (~> 2.0)
127
- prism (~> 1.5)
128
- minitest-reporters (1.8.0)
129
- ansi
130
- builder
131
- minitest (>= 5.0, < 7)
132
- ruby-progressbar
133
- net-imap (0.6.4.1)
134
- date
135
- net-protocol
136
- net-pop (0.1.2)
137
- net-protocol
138
- net-protocol (0.2.2)
139
- timeout
140
- net-smtp (0.5.1)
141
- net-protocol
142
- nio4r (2.7.5)
143
- nokogiri (1.19.4-aarch64-linux-gnu)
144
- racc (~> 1.4)
145
- nokogiri (1.19.4-arm64-darwin)
146
- racc (~> 1.4)
147
- nokogiri (1.19.4-x86_64-darwin)
148
- racc (~> 1.4)
149
- nokogiri (1.19.4-x86_64-linux-gnu)
150
- racc (~> 1.4)
151
- pp (0.6.4)
152
- prettyprint
153
- prettyprint (0.2.0)
154
- prism (1.9.0)
155
- racc (1.8.1)
156
- rack (3.2.6)
157
- rack-session (2.1.2)
158
- base64 (>= 0.1.0)
159
- rack (>= 3.0.0)
160
- rack-test (2.2.0)
161
- rack (>= 1.3)
162
- rackup (2.3.1)
163
- rack (>= 3)
164
- rails (8.1.3)
165
- actioncable (= 8.1.3)
166
- actionmailbox (= 8.1.3)
167
- actionmailer (= 8.1.3)
168
- actionpack (= 8.1.3)
169
- actiontext (= 8.1.3)
170
- actionview (= 8.1.3)
171
- activejob (= 8.1.3)
172
- activemodel (= 8.1.3)
173
- activerecord (= 8.1.3)
174
- activestorage (= 8.1.3)
175
- activesupport (= 8.1.3)
176
- bundler (>= 1.15.0)
177
- railties (= 8.1.3)
178
- rails-dom-testing (2.3.0)
179
- activesupport (>= 5.0.0)
180
- minitest
181
- nokogiri (>= 1.6)
182
- rails-html-sanitizer (1.7.0)
183
- loofah (~> 2.25)
184
- nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
185
- railties (8.1.3)
186
- actionpack (= 8.1.3)
187
- activesupport (= 8.1.3)
188
- irb (~> 1.13)
189
- rackup (>= 1.0.0)
190
- rake (>= 12.2)
191
- thor (~> 1.0, >= 1.2.2)
192
- tsort (>= 0.2)
193
- zeitwerk (~> 2.6)
194
- rake (13.4.2)
195
- rbs (4.0.3)
196
- logger
197
- prism (>= 1.6.0)
198
- tsort
199
- rdoc (8.0.0)
200
- erb
201
- prism (>= 1.6.0)
202
- rbs (>= 4.0.0)
203
- tsort
204
- reline (0.6.3)
205
- io-console (~> 0.5)
206
- rouge (5.0.0)
207
- strscan (~> 3.1)
208
- ruby-progressbar (1.13.0)
209
- securerandom (0.4.1)
210
- strscan (3.1.8)
211
- thor (1.5.0)
212
- timeout (0.6.1)
213
- tsort (0.2.0)
214
- tzinfo (2.0.6)
215
- concurrent-ruby (~> 1.0)
216
- uri (1.1.1)
217
- useragent (0.16.11)
218
- websocket-driver (0.8.2)
219
- base64
220
- websocket-extensions (>= 0.1.0)
221
- websocket-extensions (0.1.5)
222
- zeitwerk (2.8.2)
223
-
224
- PLATFORMS
225
- aarch64-linux
226
- arm64-darwin
227
- x86_64-darwin
228
- x86_64-linux
229
-
230
- DEPENDENCIES
231
- markdown_views!
232
- minitest (~> 6)
233
- minitest-reporters
234
- rake
235
-
236
- BUNDLED WITH
237
- 2.6.9
@@ -1,30 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'markdown_views/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "markdown_views"
8
- spec.version = MarkdownViews::VERSION
9
- spec.authors = ["thomas morgan"]
10
- spec.email = ["tm@iprog.com"]
11
- spec.summary = %q{Add .md template handler to Rails.}
12
- spec.description = %q{Enables Rails handling of .md templates, with optional preprocessing of ERB, HAML, etc. Also provides a markdown() view helper. Uses CommonMarker & Rouge.}
13
- spec.homepage = "https://github.com/zarqman/markdown_views"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.required_ruby_version = '>= 3.1'
22
-
23
- spec.add_dependency 'commonmarker', '>= 1.1', '< 3.0'
24
- spec.add_dependency 'rails', '>= 6.1'
25
- spec.add_dependency 'rouge', '>= 4', '< 6'
26
- spec.add_dependency 'securerandom'
27
-
28
- spec.add_development_dependency "minitest-reporters"
29
- spec.add_development_dependency "rake"
30
- end
data/test/config_test.rb DELETED
@@ -1,88 +0,0 @@
1
- require "test_helper"
2
-
3
- class ConfigTest < Minitest::Test
4
-
5
- def test_extensions
6
- processed = Commonmarker::Config.process_options(extension: MarkdownViews.extensions)[:extension]
7
- expected = {
8
- strikethrough: true,
9
- tagfilter: true,
10
- table: true,
11
- autolink: true,
12
- tasklist: false,
13
- superscript: false,
14
- # header_ids: '',
15
- header_id_prefix_in_href: false,
16
- footnotes: false,
17
- inline_footnotes: false,
18
- description_lists: false,
19
- front_matter_delimiter: '',
20
- multiline_block_quotes: false,
21
- math_dollars: false,
22
- math_code: false,
23
- math_latex: false,
24
- shortcodes: false,
25
- wikilinks_title_before_pipe: false,
26
- wikilinks_title_after_pipe: false,
27
- underline: false,
28
- spoiler: false,
29
- greentext: false,
30
- subscript: false,
31
- subtext: false,
32
- alerts: false,
33
- cjk_friendly_emphasis: true,
34
- highlight: false,
35
- insert: false,
36
- block_directive: false,
37
- }
38
- expected.except! :math_latex if Commonmarker::VERSION < '2.9'
39
- expected.except! :header_id_prefix_in_href, :block_directive if Commonmarker::VERSION < '2.8'
40
- assert_equal expected, processed
41
- end
42
-
43
- def test_parsing_opts
44
- processed = Commonmarker::Config.process_options(parse: MarkdownViews.parsing_opts)[:parse]
45
- expected = {
46
- smart: true,
47
- default_info_string: '',
48
- relaxed_tasklist_matching: false,
49
- relaxed_autolinks: false,
50
- leave_footnote_definitions: false,
51
- ignore_setext: false,
52
- sourcepos_chars: false,
53
- }
54
- expected.except! :sourcepos_chars if Commonmarker::VERSION < '2.8'
55
- assert_equal expected, processed
56
- end
57
-
58
- def test_plugins
59
- processed = Commonmarker::Config.process_plugins(MarkdownViews.plugins)
60
- expected = {
61
- syntax_highlighter: nil
62
- }
63
- assert_equal expected, processed
64
- end
65
-
66
- def test_rendering_opts
67
- processed = Commonmarker::Config.process_options(render: MarkdownViews.rendering_opts)[:render]
68
- expected = {
69
- hardbreaks: true,
70
- github_pre_lang: true,
71
- full_info_string: false,
72
- width: 80,
73
- unsafe: true,
74
- escape: false,
75
- sourcepos: false,
76
- escaped_char_spans: false,
77
- ignore_empty_links: false,
78
- gfm_quirks: false,
79
- prefer_fenced: false,
80
- tasklist_classes: false,
81
- compact_html: false,
82
- alert_style: "specific",
83
- }
84
- expected.except! :alert_style if Commonmarker::VERSION < '2.9'
85
- assert_equal expected, processed
86
- end
87
-
88
- end
data/test/render_test.rb DELETED
@@ -1,75 +0,0 @@
1
- require "test_helper"
2
-
3
- class RenderTest < Minitest::Test
4
-
5
- def test_markdown
6
- s = <<~MD
7
- # header
8
- this is *amazing*!
9
- MD
10
- o = <<~HTML
11
- <h1>header</h1>
12
- <p>this is <em>amazing</em>!</p>
13
- HTML
14
- assert_equal o, render(s)
15
- end
16
-
17
- def test_inline_html
18
- s = <<~MD
19
- ---
20
- <em>inline</em> html
21
- MD
22
- o = <<~HTML
23
- <hr />
24
- <p><em>inline</em> html</p>
25
- HTML
26
- assert_equal o, render(s)
27
- end
28
-
29
- def test_code_block
30
- s = <<~MD
31
- ```ruby
32
- def syntax_highlighting
33
- 'works too!'
34
- end
35
- ```
36
- MD
37
- o = <<~HTML
38
- <pre lang="ruby"><code class="rouge-highlight"><span class="k">def</span> <span class="nf">syntax_highlighting</span>
39
- <span class="s1">'works too!'</span>
40
- <span class="k">end</span></code></pre>
41
- HTML
42
- assert_equal o, render(s)
43
- end
44
-
45
- def test_integer
46
- o = <<~HTML
47
- <p>314</p>
48
- HTML
49
- assert_equal o, render(314)
50
- end
51
-
52
- def test_float
53
- o = <<~HTML
54
- <p>3.14</p>
55
- HTML
56
- assert_equal o, render(3.14)
57
- end
58
-
59
- def test_bigdecimal
60
- o = <<~HTML
61
- <p>3.14</p>
62
- HTML
63
- assert_equal o, render(BigDecimal('3.14'))
64
- end
65
-
66
- def test_nil
67
- assert_equal '', render(nil)
68
- end
69
-
70
-
71
- def render(*args)
72
- MarkdownViews::Renderer.render(*args)
73
- end
74
-
75
- end
@@ -1,56 +0,0 @@
1
- require "test_helper"
2
-
3
- class StripCommentsTest < Minitest::Test
4
-
5
- def test_not_greedy
6
- assert_equal "ace", strip_comments("a<!-- b -->c<!-- d -->e")
7
- assert_equal "a\nc\nd\nf", strip_comments("a\n<!-- b -->c\nd<!-- e -->\nf")
8
- end
9
-
10
- # only comment should vanish, without absorbing any outside whitespace
11
- def test_intra_line_comments
12
- assert_equal "ac", strip_comments("a<!-- b -->c"), 'no whitespace'
13
- assert_equal "\nac\n", strip_comments("\na<!-- b -->c\n"), 'no whitespace, with linefeeds'
14
- assert_equal "a c", strip_comments("a <!-- b -->c"), 'left whitespace'
15
- assert_equal "a c", strip_comments("a<!-- b --> c"), 'right whitespace'
16
- assert_equal "a c", strip_comments("a <!-- b --> c"), 'double whitespace'
17
- assert_equal "ac", strip_comments("a<!--b-->c"), 'comment w/o whitespace'
18
- assert_equal "a \nc", strip_comments("a <!-- b -->\nc"), 'trailing comment'
19
- assert_equal "a\n c", strip_comments("a\n<!-- b --> c"), 'leading comment'
20
- end
21
-
22
- # only comment should vanish, without absorbing outside whitespace
23
- def test_shared_line_multi_line_comments
24
- assert_equal "14", strip_comments("1<!-- 2\n3 -->4"), 'no whitespace'
25
- assert_equal "1 4", strip_comments("1 <!-- 2\n3 --> 4"), 'with whitespace'
26
- assert_equal "1\n 4", strip_comments("1\n <!-- 2\n3 --> 4"), 'leading whitespace on comment'
27
- assert_equal "1 \n4", strip_comments("1 <!-- 2\n3 --> \n4"), 'trailing whitespace on comment'
28
- assert_equal "1 \n 4", strip_comments("1 \n<!-- 2\n3 --> 4"), 'trailing whitespace on line'
29
- assert_equal "1 \n 4", strip_comments("1 <!-- 2\n3 -->\n 4"), 'leading whitespace on line'
30
- end
31
-
32
- # should make line vanish, including outside whitespace
33
- def test_whole_line_single_line_comments
34
- assert_equal "1\n3\n", strip_comments("1\n<!-- 2 -->\n3\n"), 'adjacent lines'
35
- assert_equal "1\r\n3\r\n", strip_comments("1\r\n<!-- 2 -->\r\n3\r\n"), 'adjacent lines w/windows LF'
36
- assert_equal "1\n\n\n3\n", strip_comments("1\n\n<!-- 2 -->\n\n3\n"), 'spaced lines'
37
- assert_equal " 1\n 3\n", strip_comments(" 1\n <!-- 2 -->\n 3\n"), 'adjacent lines indented w/spaces'
38
- assert_equal "\t1\n\t3\n", strip_comments("\t1\n\t<!-- 2 -->\n\t3\n"), 'adjacent lines indented w/tabs'
39
- assert_equal " 1\n\n\n 3\n", strip_comments(" 1\n\n <!-- 2 -->\n\n 3\n"), 'spaced lines indented w/spaces'
40
- assert_equal "1 \n \n4\t\n", strip_comments("1 \n \n<!-- 2 --> \n<!--3-->\t\n4\t\n"), 'spaced lines w/trailing whitespace'
41
- end
42
-
43
- # should make all lines vanish, including outside whitespace on same lines
44
- def test_whole_line_multi_line_comments
45
- assert_equal "1\n4\n", strip_comments("1\n<!-- 2\n3 -->\n4\n"), 'adjacent lines'
46
- assert_equal "1\n\n\n4\n", strip_comments("1\n\n<!-- 2\n3 -->\n\n4\n"), 'spaced lines'
47
- assert_equal " 1\n 4\n", strip_comments(" 1\n <!-- 2\n 3 -->\n 4\n"), 'adjacent lines indented w/spaces'
48
- assert_equal "1 \n \n4\t\n", strip_comments("1 \n \n<!-- 2 \n3 -->\t\n4\t\n"), 'spaced lines w/trailing whitespace'
49
- end
50
-
51
-
52
- def strip_comments(*args)
53
- MarkdownViews::Renderer.strip_comments(*args)
54
- end
55
-
56
- end
data/test/test_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'minitest/reporters'
2
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
3
-
4
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
5
- require "markdown_views"
6
-
7
- require "minitest/autorun"
8
-
9
-
10
- module TestHelpers
11
-
12
- # hack to make diffs more understandable
13
- # otherwise minitest sometimes truncates multi-lines diffs, making them unusable
14
- def mu_pp(obj)
15
- if obj.is_a? String
16
- super obj.gsub("\n", '\n').gsub("\t", '\t')
17
- else
18
- super
19
- end
20
- end
21
-
22
- end
23
- Minitest::Test.include TestHelpers