File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,13 +44,21 @@ def extract_yaml_from_qmd(path: Path) -> str:
4444
4545
4646def extract_body_from_quartos_md (text : str ) -> str :
47- """Return the body of the doc (from first ## heading to end). Quarto GFM
48- outputs: # Title\n Author\n Date\n \n ## First section..."""
47+ """Return the body of the doc. Quarto GFM outputs:
48+ # Title\n Author\n Date\n \n intro...\n \n ## Section...
49+ We skip the first # line and author/date until a blank line, then keep the rest."""
4950 lines = text .splitlines ()
50- for i , line in enumerate (lines ):
51- if line .strip ().startswith ("##" ):
52- return "\n " .join (lines [i :])
53- return "\n " .join (lines )
51+ i = 0
52+ # Skip first line if it's a single # title
53+ if lines and lines [0 ].strip ().startswith ("# " ) and not lines [0 ].strip ().startswith ("##" ):
54+ i = 1
55+ # Skip author/date lines until blank line
56+ while i < len (lines ) and lines [i ].strip () != "" :
57+ i += 1
58+ # Skip the blank line
59+ if i < len (lines ) and lines [i ].strip () == "" :
60+ i += 1
61+ return "\n " .join (lines [i :]) if i < len (lines ) else ""
5462
5563
5664def process_post_dir (dir_path : Path ) -> None :
You can’t perform that action at this time.
0 commit comments