@@ -324,22 +324,10 @@ def get_comments_for_slug(slug: str, path: list = []):
324324 # Need to concat those lines but still keep the comment split into
325325 # paragraphs.
326326 comment_raw = comment_file .read_text ()
327- # Empty lines will show up as zero len string elements.
328- comment_raw_list = comment_raw .split ("\n " )
329- comment_raw_list_cleaned_up = list ()
330-
331- chunk = ""
332- # Iterate until there is no next element.
333- for i , line in enumerate (comment_raw_list ):
334- try :
335- if line == "" :
336- # This is a bit clumsy and because of it I need to strip the chunk.
337- comment_raw_list_cleaned_up .append (chunk .strip ())
338- chunk = ""
339- continue
340- chunk = chunk + " " + line
341- except IndexError :
342- break
327+
328+ comment_paragraphs = list ()
329+ for paragraph in [x .strip () for x in comment_raw .split ("\n \n " )]:
330+ comment_paragraphs .append (paragraph .replace ("\n " , "" ))
343331
344332 c = Comment ()
345333 # The ULID generates a 26 char long hashes.
@@ -350,15 +338,15 @@ def get_comments_for_slug(slug: str, path: list = []):
350338 app_log .warn (f"Skipping file { comment_file } (len { len (comment_file .stem )} )" )
351339 continue
352340
353- author = comment_raw_list_cleaned_up [0 ].split ("," )
341+ author = comment_paragraphs [0 ].split ("," )
354342 if len (author ) == 0 :
355- c .created_by = comment_raw_list_cleaned_up [0 ]
343+ c .created_by = comment_paragraphs [0 ]
356344 elif len (author ) == 1 :
357345 c .created_by = author [0 ]
358346 elif len (author ) == 2 :
359347 c .created_by = author [0 ]
360348 c .created_by_contact = author [1 ]
361- c .paragraphs = comment_raw_list_cleaned_up [1 :]
349+ c .paragraphs = comment_paragraphs [1 :]
362350
363351 comments .append (c )
364352
0 commit comments