99OUTPUT_PATH = f"{ REPO .lower ()} .md"
1010GITHUB_TOKEN = os .getenv ("GITHUB_TOKEN" )
1111
12- HEADERS = {
13- "Accept" : "application/vnd.github+json" ,
14- }
12+ HEADERS = {"Accept" : "application/vnd.github+json" }
1513if GITHUB_TOKEN :
1614 HEADERS ["Authorization" ] = f"Bearer { GITHUB_TOKEN } "
1715
@@ -28,22 +26,18 @@ def fetch_contributors():
2826 r .raise_for_status ()
2927 return [user ["login" ] for user in r .json ()]
3028
31-
3229# ---------- Fetch README content ----------
3330def fetch_readme_excerpt (lines = 5 ):
34- """Fetch first few lines from README.md"""
31+ """Return the first `lines` lines from README.md (preserves empty lines). """
3532 url = f"https://raw.githubusercontent.com/{ ORG } /{ REPO } /master/README.md"
3633 r = requests .get (url )
3734 if r .status_code != 200 :
3835 return ""
39- content = r .text .strip ().splitlines ()
40- snippet = "\n " .join (content [:lines ])
41- return snippet
36+ content = r .text .splitlines () # no .strip(): keep leading/trailing blanks as they are
37+ return "\n " .join (content [:lines ])
4238
4339# ---------- Write output markdown ----------
44- def write_markdown (info , authors , longdescription = None ):
45- readme_snippet = fetch_readme_excerpt (lines = 5 )
46-
40+ def write_markdown (info , authors , readme_snippet = "" ):
4741 metadata = {
4842 "layout" : "plugin" ,
4943 "name" : info ["name" ],
@@ -58,20 +52,17 @@ def write_markdown(info, authors, longdescription=None):
5852 "shortdescription" : f"{ info ['type' ]} plugin with dependencies: { ', ' .join (info .get ('dependencies' , []))} " ,
5953 }
6054
61- with open (OUTPUT_PATH , "w" ) as f :
62- f .write ("---\n " )
63- yaml .dump (metadata , f , sort_keys = False )
55+ with open (OUTPUT_PATH , "w" , encoding = "utf-8" ) as f :
6456 f .write ("---\n " )
65-
57+ yaml .dump (metadata , f , sort_keys = False , allow_unicode = True )
58+ f .write ("---\n \n " )
6659 if readme_snippet :
6760 f .write (readme_snippet + "\n " )
6861
6962 print (f" Updated { OUTPUT_PATH } " )
70- if longdescription :
71- print ("Added description content from README.md" )
7263
7364if __name__ == "__main__" :
7465 info = fetch_plugin_info ()
7566 authors = fetch_contributors ()
76- readme_excerpt = fetch_readme_excerpt (max_lines = 5 )
77- write_markdown (info , authors , longdescription = readme_excerpt )
67+ readme_excerpt = fetch_readme_excerpt (lines = 5 )
68+ write_markdown (info , authors , readme_snippet = readme_excerpt )
0 commit comments