MCPcopy
hub / github.com/cosmicpython/book / _add_dots

Function _add_dots

render-diagrams.py:54–66  ·  view source on GitHub ↗
(source, image_id)

Source from the content-addressed store, hash-verified

52]
53
54def _add_dots(source, image_id):
55 lines = source.splitlines()
56 assert lines[0].startswith('[')
57 assert image_id in lines[0]
58 plantuml_cfg = str(Path('plantuml.cfg').absolute())
59 lines[0] = lines[0].replace('config=plantuml.cfg', f'config={plantuml_cfg}')
60 lines[0] = re.sub(r'\[ditaa, (\w+)\]', r'[ditaa, \1, scale=4]', lines[0])
61 for ix, l in enumerate(lines):
62 if include := next((i for i in INCLUDES if i in l), None):
63 lines[ix] = l.replace(include, str(Path(include).absolute()))
64 lines.insert(1, '....')
65 lines.append('....')
66 return '\n'.join(lines)
67
68
69def render_image(source, image_id):

Callers 1

render_imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected