File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,24 @@ fn format_body(body: &str, data: &Data) -> String {
310310
311311 new_body = tag_cleaner_regex. replace_all ( & new_body, "" ) . to_string ( ) ;
312312 new_body = new_body. replace ( "```dm" , "```js" ) ;
313- new_body. replace ( "\n \n \n " , "\n " )
313+
314+ let mut whitespaced_body = new_body. clone ( ) ;
315+
316+ let whitespace_cleaner = Regex :: new ( r"(\n{3,}```)|(```\n{2,})" ) . unwrap ( ) ;
317+ for capture in whitespace_cleaner. captures_iter ( & new_body) {
318+ let original = capture. get ( 0 ) . unwrap ( ) . as_str ( ) ;
319+
320+ if let Some ( _) = capture. get ( 1 ) {
321+ whitespaced_body = whitespaced_body. replace ( original, "\n \n ```" ) ;
322+ break ;
323+ }
324+
325+ if let Some ( _) = capture. get ( 2 ) {
326+ whitespaced_body = whitespaced_body. replace ( original, "```\n " )
327+ }
328+ }
329+
330+ whitespaced_body
314331}
315332
316333/// Converts the internal Zola page structure into something we can link to.
You can’t perform that action at this time.
0 commit comments