@@ -144,6 +144,30 @@ def options
144
144
expect ( htmlify ( "test {include:file:foo.rdoc}" , :rdoc ) . gsub ( /[\r ?\n ]+/ , '' ) ) . to eq '<p>test HI</p>'
145
145
end
146
146
147
+ it "preserves syntax highlighting in {include:} snippets" do
148
+ load_markup_provider ( :rdoc )
149
+ expect ( File ) . to receive ( :file? ) . with ( 'foo.rdoc' ) . and_return ( true )
150
+ expect ( File ) . to receive ( :read ) . with ( 'foo.rdoc' ) . and_return (
151
+ " !!!ruby\n x = 1\n "
152
+ )
153
+ expect ( htmlify ( "{include:file:foo.rdoc}" , :rdoc ) . gsub ( /[\r ?\n ]+/ , '' ) ) .
154
+ not_to include ( "<" )
155
+ end
156
+
157
+ it "escapes {include:} html snippets only once" do
158
+ expect ( self ) . to receive ( :html_syntax_highlight_html ) do |source |
159
+ %(<strong>#{ CGI . escapeHTML ( source ) } </strong>)
160
+ end . at_least ( :once )
161
+
162
+ load_markup_provider ( :rdoc )
163
+ expect ( File ) . to receive ( :file? ) . with ( 'foo.md' ) . and_return ( true )
164
+ expect ( File ) . to receive ( :read ) . with ( 'foo.md' ) . and_return (
165
+ " !!!html\n <h1>\n "
166
+ )
167
+ expect ( htmlify ( "{include:file:foo.md}" , :markdown ) . gsub ( /[\r ?\n ]+/ , '' ) ) .
168
+ to include ( %(<strong><h1></strong>) )
169
+ end
170
+
147
171
it "does not autolink URLs inside of {} (markdown specific)" do
148
172
log . enter_level ( Logger ::FATAL ) do
149
173
pending 'This test depends on markdown' unless markup_class ( :markdown )
@@ -648,6 +672,12 @@ def subject.respond_to?(method, include_all = false)
648
672
)
649
673
end
650
674
675
+ it "wraps but doesn't alter ruby snippets that already contain highlighting tags" do
676
+ expect ( subject . htmlify ( '<pre lang="ruby"><span class="kw">for</span></pre>' , :html ) ) . to eq (
677
+ '<pre class="code ruby"><code class="ruby"><span class="kw">for</span></code></pre>'
678
+ )
679
+ end
680
+
651
681
it "highlights source when matching a pre lang= tag" do
652
682
expect ( subject . htmlify ( '<pre lang="foo"><code>x = 1</code></pre>' , :html ) ) . to eq (
653
683
'<pre class="code foo"><code class="foo">x = 1</code></pre>'
0 commit comments