File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616import yaml
1717
18+ from openkb import frontmatter
1819from openkb .schema import PAGE_CONTENT_DIRS
1920
2021# Matches [[wikilink]] or [[subdir/link]]
@@ -500,16 +501,7 @@ def find_missing_okf_fields(wiki: Path) -> list[str]:
500501 if not subdir_path .exists ():
501502 continue
502503 for path in sorted (subdir_path .glob ("*.md" )):
503- text = _read_md (path )
504- fm = None
505- if text .startswith ("---" ):
506- end = text .find ("\n ---" , 3 )
507- if end != - 1 :
508- try :
509- fm = yaml .safe_load (text [3 :end ].strip ("\n " ))
510- except yaml .YAMLError :
511- fm = None
512- fm = fm if isinstance (fm , dict ) else {}
504+ fm = frontmatter .parse (_read_md (path ))
513505 rel = path .relative_to (wiki )
514506 type_val = fm .get ("type" )
515507 if not (isinstance (type_val , str ) and type_val .strip ()):
Original file line number Diff line number Diff line change 11"""Markdown renderers for PageIndex tree structures."""
22from __future__ import annotations
33
4- import json
5-
6-
7- def _yaml_kv_line (key : str , value : str ) -> str :
8- """Return a single YAML key-value line with the value JSON-quoted."""
9- return f"{ key } : { json .dumps (value , ensure_ascii = False )} "
4+ from openkb import frontmatter
105
116
127def _yaml_frontmatter (source_name : str , doc_id : str , description : str = "" ) -> str :
138 """Return a YAML frontmatter block for a PageIndex wiki page."""
14- lines = [_yaml_kv_line ("type" , "Summary" )]
9+ lines = [frontmatter . kv_line ("type" , "Summary" )]
1510 if description :
16- lines .append (_yaml_kv_line ("description" , description ))
11+ lines .append (frontmatter . kv_line ("description" , description ))
1712 lines .append ("doc_type: pageindex" )
18- lines .append (_yaml_kv_line ("full_text" , f"sources/{ source_name } .json" ))
13+ lines .append (frontmatter . kv_line ("full_text" , f"sources/{ source_name } .json" ))
1914 return "---\n " + "\n " .join (lines ) + "\n ---\n "
2015
2116
You can’t perform that action at this time.
0 commit comments