Navigation Menu

Skip to content
This repository has been archived by the owner on Jun 24, 2019. It is now read-only.

Commit

Permalink
fix: make the language attribute for code blocks case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kruse committed Jan 15, 2016
1 parent 48360a9 commit 20bd67e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/helpers/parser_helper.rb
Expand Up @@ -103,6 +103,12 @@ def to_doc(app, opts = {})
end
quote_level = current_ql

if l =~ /^(?:> )*~~~\s*(?:\w+)/
l = l.gsub(/~~~(\s*)(\w+)/) do
"~~~" + $1 + $2.downcase
end
end

ncnt << l
end

Expand Down
67 changes: 67 additions & 0 deletions spec/features/code_renders_with_case_insensitive_language_spec.rb
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-

require "rails_helper"

RSpec.describe "highlights with different cases" do
include CForum::Tools

it "renders to code class=block" do
messages = []
messages << create(:cf_message, content: <<HTML
~~~html
<html>
~~~
HTML
)

messages << create(:cf_message, content: <<HTML
~~~HTML
<html>
~~~
HTML
)

messages << create(:cf_message, content: <<HTML
~~~hTmL
<html>
~~~
HTML
)

messages.each do |message|
visit cf_message_path(message.thread, message)
expect(page.find(".posting-content code.block")).to have_css("span.nt", text: "<html>")
end
end

it "renders to code class=block in block quotes" do
messages = []
messages << create(:cf_message, content: <<HTML
> ~~~html
> <html>
> ~~~
HTML
)

messages << create(:cf_message, content: <<HTML
> ~~~html
> <html>
> ~~~
HTML
)

messages << create(:cf_message, content: <<HTML
> ~~~html
> <html>
> ~~~
HTML
)

messages.each do |message|
visit cf_message_path(message.thread, message)
expect(page.find(".posting-content code.block")).to have_css("span.nt", text: "<html>")
end
end
end

# eof

0 comments on commit 20bd67e

Please sign in to comment.