diff options
Diffstat (limited to 'repo/www')
| -rwxr-xr-x | repo/www/generate-index.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/repo/www/generate-index.py b/repo/www/generate-index.py index 3fe1212..ab5b2a4 100755 --- a/repo/www/generate-index.py +++ b/repo/www/generate-index.py @@ -108,35 +108,35 @@ def main(arguments): stylesheets, variables ) - if readme is not None: - repo_top = Repo(search_parent_directories=True).working_dir - readme_path = Path(repo_top, target, readme) - - # If the README doesn't have a title, give a default to pandoc - # out-of-band. - if not has_title(readme_path): - metadata['pagetitle'] = target or 'README' - - with NamedTemporaryFile(mode='w+') as toc: - toc.write(f'<h1>{toc_title}</h1>\n') + if readme is None: + with NamedTemporaryFile(suffix='.md') as dummy_readme, \ + NamedTemporaryFile(mode='w+') as toc: toc.write(html_toc) toc.flush() + metadata['pagetitle'] = toc_title + metadata['title'] = 'Index' + pandoc.run( - readme_path, include_after=(toc.name,), metadata=metadata + dummy_readme.name, include_after=(toc.name,), metadata=metadata ) - return + return - with NamedTemporaryFile(suffix='.md') as dummy_readme, \ - NamedTemporaryFile(mode='w+') as toc: + repo_top = Repo(search_parent_directories=True).working_dir + readme_path = Path(repo_top, target, readme) + + # If the README doesn't have a title, give a default to pandoc + # out-of-band. + if not has_title(readme_path): + metadata['pagetitle'] = target or 'README' + + with NamedTemporaryFile(mode='w+') as toc: + toc.write(f'<h1>{toc_title}</h1>\n') toc.write(html_toc) toc.flush() - metadata['pagetitle'] = toc_title - metadata['title'] = 'Index' - pandoc.run( - dummy_readme.name, include_after=(toc.name,), metadata=metadata + readme_path, include_after=(toc.name,), metadata=metadata ) |
