| 27 | |
| 28 | |
| 29 | def render_images(chapter_name): |
| 30 | print('Rendering images for', chapter_name) |
| 31 | raw_contents = Path(f'{chapter_name}.html').read_text() |
| 32 | parsed_html = html.fromstring(raw_contents) |
| 33 | |
| 34 | for image_block in parsed_html.cssselect('.imageblock'): |
| 35 | [img] = image_block.cssselect('img') |
| 36 | image_id = img.get('src').replace('images/', '').replace('.png', '') |
| 37 | print(image_id) |
| 38 | |
| 39 | parent = image_block.getparent() |
| 40 | next_sibling_pos = parent.index(image_block) + 1 |
| 41 | try: |
| 42 | next_element = parent[next_sibling_pos] |
| 43 | except IndexError: |
| 44 | continue |
| 45 | if 'image-source' in next_element.classes: |
| 46 | code = next_element.cssselect('pre')[0].text |
| 47 | render_image(code, image_id) |
| 48 | |
| 49 | INCLUDES = [ |
| 50 | 'images/C4_Context.puml', |