html-pipeline-rouge_filter 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3764c586c76cd0455f21d18e39e7c41c061b3d54
4
- data.tar.gz: 305b56c8c4758a7ec4354168fbc39cbaad025044
3
+ metadata.gz: d3435aff7d37f882d774a516c1020d59b6e4468e
4
+ data.tar.gz: bba6bbf9841d22c6d867f302a28f29250ffcbd9c
5
5
  SHA512:
6
- metadata.gz: 35d277942a7eb834d9ea2afb1121b21db61b18292fe017ef064f8189a07063053c507e9d820b9ea09b21d9610156c49eb6eaceb54afe04e04bdcd267c660d4db
7
- data.tar.gz: 0d7f67970f355c47b6fdff2b65bd74dc9fde84d6b8ef86652b08b5a54882e67ae58c326d0d29b0ce8f9c8598a7f16b3ab54d8f080f6bd74eaa6d4ffc9d7453c3
6
+ metadata.gz: 77a5575eb8b6d8f06afe2e91615820995c38a4e1b55873456c558cf07deefd2fba5c05631bb4142101e2605f5b55c23361f693ea41183399c71cae38314d0e94
7
+ data.tar.gz: 448789503c78cd2676076857add9760fc6a88adcd345d7a1f98b124a65cfe84f38dacacfc9e2b416224b8aa8a53d89269cbbb1d9fdd32ebcc3481ff64fdfe8a1
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.4 - 2016.04.16
6
+
7
+ - Replace `<br>` to newline via `replace_br` option in context hash [#7](https://github.com/JuanitoFatas/html-pipeline-rouge_filter/pull/7) by @allenwq
8
+
5
9
  ## 1.0.3 - 2016.02.10
6
10
 
7
11
  - Generate line numbers via `line_numbers` option in context hash [#5](https://github.com/JuanitoFatas/html-pipeline-rouge_filter/pull/5) by @lowjoel
data/README.md CHANGED
@@ -58,8 +58,12 @@ Prints (without the linebreaks):
58
58
  </pre>
59
59
  ```
60
60
 
61
- You can specify line numbers via `line_numbers` option in
62
- [context](https://github.com/jch/html-pipeline#examples) hash.
61
+ You can specify following options in
62
+ [context](https://github.com/jch/html-pipeline#examples) hash:
63
+
64
+ `line_numbers`: Line numbers will be displayed if set to true.
65
+
66
+ `replace_br`: `<br>` tags in the code will be replaced with new line characters (`\n`) if set to true.
63
67
 
64
68
  ## Contributing
65
69
 
@@ -13,6 +13,7 @@ module HTML
13
13
  default = must_str(context[:highlight])
14
14
  next unless lang = node["lang"] || default
15
15
  next unless lexer = lexer_for(lang)
16
+ node.css("br").each { |br| br.replace("\n") } if replace_br
16
17
  text = node.inner_text
17
18
  html = highlight_with(lexer, text)
18
19
  next if html.nil?
@@ -39,6 +40,10 @@ module HTML
39
40
  context[:line_numbers] || false
40
41
  end
41
42
 
43
+ def replace_br
44
+ context[:replace_br] || false
45
+ end
46
+
42
47
  def formatter(css_class: default_css_class)
43
48
  Rouge::Formatters::HTML.new(css_class: css_class,
44
49
  line_numbers: line_numbers)
@@ -2,6 +2,6 @@
2
2
  # and we don't want to define it here inadvertently
3
3
  module HTML_Pipeline
4
4
  class RougeFilter
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.4"
6
6
  end
7
7
  end
@@ -88,4 +88,13 @@ class HTML::Pipeline::RougeFilterTest < Minitest::Test
88
88
 
89
89
  assert_kind_of Rouge::Lexers::Shell, filter.lexer_for("shell")
90
90
  end
91
+
92
+ def test_replacing_br
93
+ filter = RougeFilter.new \
94
+ "<pre lang='ruby'>hello<br>world</pre>", replace_br: true
95
+
96
+ doc = filter.call
97
+ assert_equal "<pre class=\"highlight highlight-ruby\"><code>"\
98
+ "<span class=\"n\">hello</span>\n<span class=\"n\">world</span></code></pre>\n", doc.to_html
99
+ end
91
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-rouge_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito Fatas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-pipeline
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.5.1
94
+ rubygems_version: 2.6.2
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Rouge integration with html-pipeline.