Skip to content

Commit

Permalink
script to print out image filenames to figure numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
hjwp committed Jan 15, 2020
1 parent 723a656 commit 89f741a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions print_figure_numbers_xref_to_image_filenames.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
from pathlib import Path
import re

for path in sorted(Path(__file__).absolute().parent.glob('*.asciidoc')):
images = re.findall(r'::images/(\w+\.png)', path.read_text())
if not images:
continue
chapter_no = re.search(r'chapter_(\d\d)', str(path))
if chapter_no:
chapter_no = str(int(chapter_no.group(1)))
else:
chapter_no = '??'
print(path.name)
for ix, image in enumerate(images):
print(f' Figure {chapter_no}.{ix+1}: {image}')

0 comments on commit 89f741a

Please sign in to comment.