(app)
| 340 | |
| 341 | |
| 342 | def prepare(app): |
| 343 | with open(DIR.parent / "README.rst") as f: |
| 344 | contents = f.read() |
| 345 | |
| 346 | if app.builder.name == "latex": |
| 347 | # Remove badges and stuff from start |
| 348 | contents = contents[contents.find(r".. start") :] |
| 349 | |
| 350 | # Filter out section titles for index.rst for LaTeX |
| 351 | contents = re.sub(r"^(.*)\n[-~]{3,}$", r"**\1**", contents, flags=re.MULTILINE) |
| 352 | |
| 353 | with open(DIR / "readme.rst", "w") as f: |
| 354 | f.write(contents) |
| 355 | |
| 356 | |
| 357 | def clean_up(app, exception): # noqa: ARG001 |