Skip to content

Commit 941a013

Browse files
committed
fix for newlines being stripped within codemirror sections
1 parent fe01d5d commit 941a013

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

_plugins/codemirror.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
module Jekyll
77
class CodeMirror < Liquid::Block
8+
89
def initialize(tag_name, lang, tokens)
910
super
1011
@lang = lang.to_s.strip
1112
end
1213

1314
def render(context)
1415
require 'cgi'
15-
'<pre class="codemirror" data-lang="' + @lang.to_s + '">' + CGI.escapeHTML(super.strip) + '</pre>'
16+
'<textarea class="codemirror" data-lang="' + @lang.to_s + '">' + CGI.escapeHTML(super.strip) + '</textarea>'
1617
end
1718
end
1819
end

_plugins/collapse_newlines.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ def write(dest)
3838
# If the file is HTML, newlines within <pre> elements should not be
3939
# collapsed.
4040
pre_regexp = /<\/?pre[^>]*>/i
41-
pre_list = output.scan(pre_regexp)
42-
blocks = output.split(pre_regexp)
41+
textarea_regexp = /<\/?textarea[^>]*>/i
42+
43+
pre_list = output.scan(Regexp.union(pre_regexp, textarea_regexp))
44+
blocks = output.split(Regexp.union(pre_regexp, textarea_regexp))
4345

4446
collapsed_blocks = []
4547
blocks.each_with_index do |block, i|

0 commit comments

Comments
 (0)