@@ -86,10 +86,7 @@ def convert_md(md_text: str) -> str:
8686
8787 return replaced_md
8888
89- def lim (s ): # literal if multi-line
90- if '\n ' in s :
91- return ruamel .yaml .scalarstring .LiteralScalarString (s )
92- return s
89+
9390
9491def format_content (pathlist , docs_path ):
9592 """
@@ -146,18 +143,30 @@ def format_content(pathlist, docs_path):
146143 if path .name != "projects.md" :
147144 post .metadata ["sidebar" ] = {"nav" : "projects" }
148145
149- data = {"full_description" : lim ( post .content ) }
146+ data = {"full_description" : post .content }
150147 post .metadata .update (data )
151148
152- clean_metadata = {}
153- for key , value in post .metadata .items ():
154- if isinstance (value , ruamel .yaml .scalarstring .LiteralScalarString ):
155- clean_metadata [key ] = str (value )
156- else :
157- clean_metadata [key ] = value
149+ # Use ruamel.yaml for proper literal block scalar formatting
150+ yaml = ruamel .yaml .YAML ()
151+ yaml .preserve_quotes = True
152+ yaml .width = 4096
153+
154+ # Create the frontmatter manually to ensure literal block scalars
155+ metadata_copy = post .metadata .copy ()
156+
157+ # Convert multiline strings to literal scalars
158+ for key , value in metadata_copy .items ():
159+ if isinstance (value , str ) and '\n ' in value :
160+ metadata_copy [key ] = ruamel .yaml .scalarstring .LiteralScalarString (value )
161+
162+ # Manually construct the frontmatter
163+ from io import StringIO
164+ stream = StringIO ()
165+ yaml .dump (metadata_copy , stream )
166+ yaml_content = stream .getvalue ()
158167
159- # Serialize back to frontmatter+ content
160- formatted_content = frontmatter . dumps ( clean_post )
168+ # Build the full content with frontmatter
169+ formatted_content = f"--- \n { yaml_content } --- \n { post . content } "
161170
162171 # Convert Markdown image embeds → HTML and copy assets
163172 converted_content = convert_md_images_to_html (
@@ -193,4 +202,4 @@ def main():
193202 format_content (projects_extended_project_pathlist , docs_posts_dir )
194203
195204if __name__ == "__main__" :
196- main ()
205+ main ()
0 commit comments