',h,flags=re.MULTILINE)
-
- # Links
- h=re.sub(r'\[([^\]]+)\]\(([^\)]+)\)',r'\1',h)
-
- # Bold/italic (after headers to avoid **text:** becoming headings)
- h=re.sub(r'\*\*([^\*]+)\*\*',r'\1',h)
- h=re.sub(r'\*([^\*\n]+)\*',r'\1',h)
-
- # Inline code
- h=re.sub(r'`([^`]+)`',r'\1',h)
-
- # Restore code blocks
- for i, block in enumerate(code_blocks):
- content = re.search(r'```[^\n]*\n(.*?)```', block, re.DOTALL).group(1)
- h = h.replace(f'___CODE_BLOCK_{i}___', f'
{content}
')
-
- # Process line by line for paragraphs and lists
- lines=h.split('\n')
- result=[]
- in_ul=False
- in_pre=False
- para_buffer=[]
-
- def flush_para():
- if para_buffer:
- result.append('
' + ' '.join(para_buffer) + '
')
- para_buffer.clear()
-
- for line in lines:
- s=line.strip()
-
- # Track pre blocks
- if '
' in line:
- flush_para()
- in_pre=True
- result.append(line)
- continue
- if '
' in line:
- in_pre=False
- result.append(line)
- continue
- if in_pre:
- result.append(line)
- continue
-
- # Handle list items
- if s.startswith(('- ','* ')):
- flush_para()
- if not in_ul:
- result.append('
')
-for s in secs:
- a=s['title'].lower().replace(' ','-').replace('/','').replace('.','')
- parts.append(f'
{s["title"]}
')
- for i in s['items']:
- parts.append(f'
{i["definition"]}
')
- if i['description']:
- parts.append(f'
{md2html(i["description"])}
')
-(out/'reference.html').write_text(HTML_TEMPLATE.format(title='API Reference',content='\n'.join(parts)),encoding='utf-8')
-print(f'✓ reference.html ({sum(len(s["items"]) for s in secs)} items)')
-print('Complete!')
--
cgit v1.2.3