# cPy - show an svg drawing in a browser
# provided by Anthony Vogelaar,  Perth Scotland
# rev 0.10  2024-09-16  initial release

import  os;         os.system('clear')

html = '''
<!DOCTYPE html>
<html lang="en">
    <head>
	    <meta charset="utf-8" />
	    <link rel="icon" href="data:,">
	    <title>Title</title>
    </head>
    <body>
        <h1>Hello World</h1>
<!--    %1  -->
    </body>
</html>
'''

svg = '''
<svg width="64" height="64">
    <circle cx="32" cy="32" r="30" stroke="red" stroke-width="4" fill="white"/>
</svg>
'''

# ========================= main =============================

def main_1():
    with open('test.html', 'w') as f:
        for line in html.split('\n'):
            f.write(f'{line}\n')
    os.system('google-chrome file:///home/ajv/work/svg/2_show_svg/test.html')


def main_2():
    with open('test.html', 'w') as f:
        for line in html.split('\n'):
            if line.find('%1') >= 0: line = svg
            f.write(f'{line}\n')
    os.system('google-chrome file:///home/ajv/work/svg/2_show_svg/test.html')


# main_1()
main_2()

# ========================== end ============================
