# NAME
-yt\-dlp \- A youtube-dl fork with additional features and patches
+yt\-dlp \- A feature\-rich command\-line audio/video downloader
# SYNOPSIS
'', readme)
+def _convert_code_blocks(readme):
+ current_code_block = None
+
+ for line in readme.splitlines(True):
+ if current_code_block:
+ if line == current_code_block:
+ current_code_block = None
+ yield '\n'
+ else:
+ yield f' {line}'
+ elif line.startswith('```'):
+ current_code_block = line.count('`') * '`' + '\n'
+ yield '\n'
+ else:
+ yield line
+
+
+def convert_code_blocks(readme):
+ return ''.join(_convert_code_blocks(readme))
+
+
def move_sections(readme):
MOVE_TAG_TEMPLATE = '<!-- MANPAGE: MOVE "%s" SECTION HERE -->'
sections = re.findall(r'(?m)^%s$' % (
def filter_options(readme):
section = re.search(r'(?sm)^# USAGE AND OPTIONS\n.+?(?=^# )', readme).group(0)
+ section_new = section.replace('*', R'\*')
+
options = '# OPTIONS\n'
- for line in section.split('\n')[1:]:
+ for line in section_new.split('\n')[1:]:
mobj = re.fullmatch(r'''(?x)
\s{4}(?P<opt>-(?:,\s|[^\s])+)
(?:\s(?P<meta>(?:[^\s]|\s(?!\s))+))?
return readme.replace(section, options, 1)
-TRANSFORM = compose_functions(filter_excluded_sections, move_sections, filter_options)
+TRANSFORM = compose_functions(filter_excluded_sections, convert_code_blocks, move_sections, filter_options)
def main():