77 */
88
99use crate :: pandoc:: ast_context:: ASTContext ;
10- use crate :: pandoc:: inline:: { Delete , EditComment , Highlight , Inline , Insert , Inlines } ;
11- use crate :: pandoc:: location:: node_source_info_with_context;
10+ use crate :: pandoc:: inline:: { Delete , EditComment , Highlight , Inline , Inlines , Insert , Space , Str } ;
11+ use crate :: pandoc:: location:: { SourceInfo , node_source_info_with_context} ;
12+ use once_cell:: sync:: Lazy ;
13+ use regex:: Regex ;
1214use std:: collections:: HashMap ;
1315use std:: io:: Write ;
1416
1517use super :: pandocnativeintermediate:: PandocNativeIntermediate ;
18+ use super :: text_helpers:: apply_smart_quotes;
1619
1720macro_rules! process_editorial_mark {
1821 ( $struct_name: ident) => {
@@ -23,6 +26,7 @@ macro_rules! process_editorial_mark {
2326 children: Vec <( String , PandocNativeIntermediate ) >,
2427 context: & ASTContext ,
2528 ) -> PandocNativeIntermediate {
29+ let whitespace_re: Lazy <Regex > = Lazy :: new( || Regex :: new( r"\s+" ) . unwrap( ) ) ;
2630 let mut attr = ( "" . to_string( ) , vec![ ] , HashMap :: new( ) ) ;
2731 let mut content: Inlines = vec![ ] ;
2832
@@ -37,6 +41,32 @@ macro_rules! process_editorial_mark {
3741 PandocNativeIntermediate :: IntermediateInlines ( mut inlines) => {
3842 content. append( & mut inlines) ;
3943 }
44+ PandocNativeIntermediate :: IntermediateBaseText ( text, range) => {
45+ if let Some ( _) = whitespace_re. find( & text) {
46+ content. push( Inline :: Space ( Space {
47+ source_info: SourceInfo :: new(
48+ if context. filenames. is_empty( ) {
49+ None
50+ } else {
51+ Some ( 0 )
52+ } ,
53+ range,
54+ ) ,
55+ } ) )
56+ } else {
57+ content. push( Inline :: Str ( Str {
58+ text: apply_smart_quotes( text) ,
59+ source_info: SourceInfo :: new(
60+ if context. filenames. is_empty( ) {
61+ None
62+ } else {
63+ Some ( 0 )
64+ } ,
65+ range,
66+ ) ,
67+ } ) )
68+ }
69+ }
4070 PandocNativeIntermediate :: IntermediateUnknown ( _) => {
4171 // Skip unknown nodes (delimiters, etc.)
4272 }
0 commit comments