from imgui_bundle import imgui, immapp, imgui_md
import sys

def gui():
    imgui.text("Markdown Test")
    imgui.separator()
    
    md = """
# Header 1
## Header 2
This is **bold** and *italic*.

* List item 1
* List list 2

[Google](https://google.com)

```python
def hello():
    print("world")
```

<div class="test-div">This is inside a div</div>
"""
    imgui_md.render(md)

def on_html_div(div_class: str, opening: bool):
    print(f"HTML DIV: class={div_class}, opening={opening}")
    if opening:
        imgui.push_style_color(imgui.Col_.text.value, imgui.ImColor(255, 0, 0, 255).value)
    else:
        imgui.pop_style_color()

def main():
    options = imgui_md.MarkdownOptions()
    options.callbacks.on_html_div = on_html_div
    immapp.run(gui, with_markdown_options=options, window_size=(600, 600))

if __name__ == "__main__":
    main()
