@@ -177,7 +177,7 @@ fn parse_event(event: Event, iterator: &mut EventIterator) -> Result<Node, Parse
177
177
match event {
178
178
Event :: Start ( tag) => parse_start ( tag, iterator) ,
179
179
Event :: End ( _) => Ok ( iterator. get_not_implemented ( ) ) , // do nothing
180
- Event :: Code ( code ) => parse_code ( code , iterator) . map ( |x| x. into ( ) ) ,
180
+ Event :: Code ( _ ) => parse_code ( iterator) . map ( |x| x. into ( ) ) ,
181
181
Event :: Text ( _) => parse_text ( iterator) . map ( |x| x. into ( ) ) ,
182
182
Event :: Html ( html) => parse_html ( html, iterator) . map ( |x| x. into ( ) ) ,
183
183
Event :: InlineHtml ( html) => parse_html ( html, iterator) . map ( Into :: into) ,
@@ -318,7 +318,11 @@ fn parse_code_block(code_block_kind: CodeBlockKind, iterator: &mut EventIterator
318
318
while let Some ( event) = iterator. next ( ) {
319
319
match event {
320
320
Event :: End ( TagEnd :: CodeBlock ) => break ,
321
- Event :: Text ( event_text) => code. push_str ( event_text. as_ref ( ) ) ,
321
+ Event :: Text ( _) => {
322
+ let last_range = iterator. get_last_range ( ) ;
323
+ let raw_text = & iterator. file_text [ last_range] ;
324
+ code. push_str ( raw_text)
325
+ }
322
326
_ => {
323
327
return Err ( ParseError :: new (
324
328
iterator. get_last_range ( ) ,
@@ -351,10 +355,14 @@ fn parse_code_block(code_block_kind: CodeBlockKind, iterator: &mut EventIterator
351
355
} )
352
356
}
353
357
354
- fn parse_code ( code : CowStr , iterator : & mut EventIterator ) -> Result < Code , ParseError > {
358
+ fn parse_code ( iterator : & mut EventIterator ) -> Result < Code , ParseError > {
359
+ let mut raw_text = & iterator. file_text [ iterator. get_last_range ( ) ] ;
360
+ while raw_text. starts_with ( '`' ) && raw_text. ends_with ( '`' ) {
361
+ raw_text = & raw_text[ 1 ..raw_text. len ( ) - 1 ] ;
362
+ }
355
363
Ok ( Code {
356
364
range : iterator. get_last_range ( ) ,
357
- code : String :: from ( code . as_ref ( ) ) ,
365
+ code : raw_text . to_string ( ) ,
358
366
} )
359
367
}
360
368
0 commit comments