@@ -207,26 +207,11 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
207207 let should_panic;
208208 let ignore;
209209 let edition;
210- if let Some ( Event :: Start ( Tag :: CodeBlock ( kind) ) ) = event {
211- let parse_result = match kind {
212- CodeBlockKind :: Fenced ( ref lang) => {
213- LangString :: parse_without_check ( & lang, self . check_error_codes , false )
214- }
215- CodeBlockKind :: Indented => Default :: default ( ) ,
216- } ;
217- if !parse_result. rust {
218- return Some ( Event :: Start ( Tag :: CodeBlock ( kind) ) ) ;
219- }
220- compile_fail = parse_result. compile_fail ;
221- should_panic = parse_result. should_panic ;
222- ignore = parse_result. ignore ;
223- edition = parse_result. edition ;
210+ let kind = if let Some ( Event :: Start ( Tag :: CodeBlock ( kind) ) ) = event {
211+ kind
224212 } else {
225213 return event;
226- }
227-
228- let explicit_edition = edition. is_some ( ) ;
229- let edition = edition. unwrap_or ( self . edition ) ;
214+ } ;
230215
231216 let mut origtext = String :: new ( ) ;
232217 for event in & mut self . inner {
@@ -241,6 +226,35 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
241226 let lines = origtext. lines ( ) . filter_map ( |l| map_line ( l) . for_html ( ) ) ;
242227 let text = lines. collect :: < Vec < Cow < ' _ , str > > > ( ) . join ( "\n " ) ;
243228
229+ let parse_result = match kind {
230+ CodeBlockKind :: Fenced ( ref lang) => {
231+ let parse_result =
232+ LangString :: parse_without_check ( & lang, self . check_error_codes , false ) ;
233+ if !parse_result. rust {
234+ return Some ( Event :: Html (
235+ format ! (
236+ "<div class=\" example-wrap\" >\
237+ <pre{}>{}</pre>\
238+ </div>",
239+ format!( " class=\" language-{}\" " , lang) ,
240+ text,
241+ )
242+ . into ( ) ,
243+ ) ) ;
244+ }
245+ parse_result
246+ }
247+ CodeBlockKind :: Indented => Default :: default ( ) ,
248+ } ;
249+
250+ compile_fail = parse_result. compile_fail ;
251+ should_panic = parse_result. should_panic ;
252+ ignore = parse_result. ignore ;
253+ edition = parse_result. edition ;
254+
255+ let explicit_edition = edition. is_some ( ) ;
256+ let edition = edition. unwrap_or ( self . edition ) ;
257+
244258 let playground_button = self . playground . as_ref ( ) . and_then ( |playground| {
245259 let krate = & playground. crate_name ;
246260 let url = & playground. url ;
0 commit comments