Skip to content

Commit

Permalink
v0.6.2. See CHANGELOG.md for details.
Browse files Browse the repository at this point in the history
Merge branch 'escape-code'

* escape-code:
  CHANGELOG, Version, and Gemspec Date
  [escape-code] Added Aruba test for escaping html
  HTML-escape special characters in code blocks
  • Loading branch information
jedcn committed Jan 20, 2015
2 parents 5863f26 + 667e920 commit ef1e6b7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### 0.6.2 / 2015-01-19

[full changelog](https://github.com/jedcn/reveal-ck/compare/v0.6.1...v0.6.2)

#### Bug Fix: Escape HTML characters in Markdown code snippets

This is a fix for Issue #32.

reveal-ck now escapes HTML characters in markdown code snippets.

Thanks to [@skirino][skirino] for both reporting the issue and fixing it!

[skirino]: https://github.com/skirino

### 0.6.1 / 2015-01-09

[full changelog](https://github.com/jedcn/reveal-ck/compare/v0.6.0...v0.6.1)
Expand Down
22 changes: 22 additions & 0 deletions features/generate-with-markdown.feature
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,25 @@ Feature: Slides with markdown
| //section[4]/section[2]/h1[text()="Column 2, Slide 2"] | Column 2, Slide 2 |
| //section[4]/section[3]/h1[text()="Column 2, Slide 3"] | Column 2, Slide 3 |
| //section[5]/h1[text()="Last"] | Last Slide |

Scenario: Creating a slide with HTML special characters
Given a file named "slides.md" with:
"""
```
user=> (atom 10)
#<Atom@6cbda790: 10>
```
"""
When I run `reveal-ck generate`
Then the exit status should be 0
And the file "slides/index.html" should have html matching the xpath:
| //section/pre/code[contains(., 'user=>')] | first line of escaped code |
| //section/pre/code[contains(., "#<Atom@6cbda790: 10>")] | second line of escaped code |
And the file "slides/index.html" should contain:
"""
user=&gt; (atom 10)
"""
And the file "slides/index.html" should contain:
"""
#&lt;Atom@6cbda790: 10&gt;
"""
8 changes: 5 additions & 3 deletions lib/reveal-ck/markdown/slide_markdown.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'cgi'
require 'redcarpet'

module RevealCK
Expand All @@ -13,12 +14,13 @@ def postprocess(doc)
end

def block_code(code, language)
escaped = CGI.escape_html(code)
if language.nil?
"<pre><code>#{code}</code></pre>"
"<pre><code>#{escaped}</code></pre>"
elsif language == 'notes' || language == 'note'
"<aside class='notes'>#{code}</aside>"
"<aside class='notes'>#{escaped}</aside>"
else
"<pre><code class=\"#{language}\">#{code}</code></pre>"
"<pre><code class=\"#{language}\">#{escaped}</code></pre>"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/reveal-ck/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RevealCK::VERSION is the current version of reveal-ck
module RevealCK
VERSION = '0.6.1'
VERSION = '0.6.2'
end
2 changes: 1 addition & 1 deletion reveal-ck.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Gem::Specification.new do |s|
s.executables = ['reveal-ck']
s.require_paths = ['lib']

s.date = '2014-11-01'
s.date = '2015-01-19'
s.extra_rdoc_files = [
'LICENSE',
'README.md'
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/reveal-ck/markdown/slide_markdown_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ def adder(a, b); a + b; end
expect(output).to include 'a + b'
end

it 'converts special characters in ``` block to entity references' do
output = render_markdown <<-eos
```
<p>"&"</p>
```
eos
expect(output).to include '<pre><code>'
expect(output).to include '</code></pre>'
expect(output).to include '&lt;p&gt;&quot;&amp;&quot;&lt;/p&gt;'
end

it 'wraps ```ruby code in a <pre> and <code class="ruby">' do
output = render_markdown <<-eos
```ruby
Expand Down

0 comments on commit ef1e6b7

Please sign in to comment.