@@ -47,23 +47,33 @@ def load_entries(community_dir: Path) -> list[dict]:
4747 return entries
4848
4949
50+ def _escape_pipes (value : str ) -> str :
51+ return value .replace ("|" , "\\ |" )
52+
53+
5054def _links_cell (links : dict ) -> str :
51- parts = [f"[{ label } ]({ url } )" for label , url in links .items () if str (url ).startswith ("http" )]
55+ parts = [
56+ f"[{ _escape_pipes (str (label ))} ]({ url } )"
57+ for label , url in links .items ()
58+ if str (url ).startswith ("http" )
59+ ]
5260 return "<br>" .join (parts ) if parts else ""
5361
5462
5563def _row (entry : dict ) -> str :
56- project = f"[{ entry ['title' ]} ]({ entry ['slug' ]} /)"
64+ project = f"[{ _escape_pipes ( entry ['title' ]) } ]({ entry ['slug' ]} /)"
5765 author = (
58- f"[@{ entry ['author' ]} ](https://github.com/{ entry ['author' ]} )" if entry ["author" ] else ""
66+ f"[@{ _escape_pipes (entry ['author' ])} ](https://github.com/{ entry ['author' ]} )"
67+ if entry ["author" ]
68+ else ""
5969 )
60- tags = ", " .join (str (t ) for t in entry ["tags" ])
70+ tags = _escape_pipes ( ", " .join (str (t ) for t in entry ["tags" ]) )
6171 hosted = "hosted" if entry ["hosted" ] else ""
6272 cells = [
6373 project ,
6474 author ,
65- entry ["description" ],
66- entry ["opik_platform" ],
75+ _escape_pipes ( entry ["description" ]) ,
76+ _escape_pipes ( entry ["opik_platform" ]) ,
6777 _links_cell (entry ["links" ]),
6878 hosted ,
6979 tags ,
@@ -83,12 +93,14 @@ def render_index(entries: list[dict]) -> str:
8393
8494
8595def write_index (community_dir : Path ) -> None :
86- (community_dir / "README.md" ).write_text (render_index (load_entries (community_dir )))
96+ (community_dir / "README.md" ).write_text (
97+ render_index (load_entries (community_dir )), encoding = "utf-8"
98+ )
8799
88100
89101def check_index (community_dir : Path ) -> bool :
90102 readme = community_dir / "README.md"
91- current = readme .read_text () if readme .is_file () else ""
103+ current = readme .read_text (encoding = "utf-8" ) if readme .is_file () else ""
92104 return current == render_index (load_entries (community_dir ))
93105
94106
0 commit comments