22
33from lib .macro_storage_format_builder import MacroStorageFormatBuilder
44from lib .util import Util
5-
5+ import re
66
77class MacroStorageFormatParser :
88 def __init__ (
@@ -15,18 +15,10 @@ def __init__(
1515 self .util = Util (forceUUIDsZeroed )
1616
1717 def _split_macro_body_on_content_block (self , macro_body : str ) -> tuple [str , str ]:
18- if "[content]\r \n " in macro_body :
19- splitted = macro_body .split ("[content]\r \n " , 1 )
20- return (splitted [0 ], splitted [1 ])
21- if "[content]\r " in macro_body :
22- splitted = macro_body .split ("[content]\r " , 1 )
23- return (splitted [0 ], splitted [1 ])
24- if "[content]\n \r " in macro_body :
25- splitted = macro_body .split ("[content]\n \r " , 1 )
26- return (splitted [0 ], splitted [1 ])
27- if "[content]\n " in macro_body :
28- splitted = macro_body .split ("[content]\n " , 1 )
29- return (splitted [0 ], splitted [1 ])
18+ if "[content]" in macro_body :
19+ splitted = re .split (r'\[content\]\s*(\r\n|\r|\n\r|\n)' , macro_body , maxsplit = 1 )
20+ # re.split splits also the capturing group \n as [1]!
21+ return (splitted [0 ], splitted [2 ])
3022 return ("ERROR SPLITTING AT [CONTENT]" , "ERROR: INVALID NEWLINE" )
3123
3224 def transform (self ):
0 commit comments