Skip to content

Commit 5c43b1b

Browse files
committed
update imgui_md (fix spacing issues between blocks, paragraph, etc)
1 parent e55ff4e commit 5c43b1b

3 files changed

Lines changed: 166 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ LaTeX math is now supported in the Markdown renderer, using the new `imgui_micro
5151

5252
### Other Markdown improvements
5353

54+
- Fix word wrapping issues around transitions between bold/italic and normal
55+
- Make spacing between blocks, headers and paragraphs more coherent
5456
- Adaptive code snippet colors: new `SnippetTheme::Auto` picks dark or light based on current ImGui theme
5557
- TextEdit no longer shows a caret in coded blocks.
5658

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
"""Sandbox: visual diagnosis of inter-block spacing in imgui_md.
2+
3+
Lays out every block-to-block transition we care about so the gaps can
4+
be eyeballed side-by-side.
5+
A. content right after <summary>
6+
B. block-to-block transitions (P/UL/OL/quote/code/table/HR)
7+
C. header levels H1..H5
8+
D. nested lists and adjacent lists
9+
"""
10+
11+
from imgui_bundle import immapp, imgui, imgui_md
12+
13+
14+
SECTIONS = {
15+
"A. content right after <summary>": r"""
16+
<details open>
17+
<summary>Open summary, then a paragraph</summary>
18+
19+
Paragraph immediately after the summary closes. Note the gap above.
20+
21+
</details>
22+
23+
<details open>
24+
<summary>Open summary, then a UL</summary>
25+
26+
- list item right after summary
27+
- second item
28+
29+
</details>
30+
31+
<details open>
32+
<summary>Open summary, then a code block</summary>
33+
34+
```python
35+
print("hello")
36+
```
37+
38+
</details>
39+
40+
<details open>
41+
<summary>Open summary, then a quote</summary>
42+
43+
> A blockquote right after the summary.
44+
45+
</details>
46+
""",
47+
48+
"B. block-to-block transitions": r"""
49+
A short paragraph.
50+
51+
Another paragraph. Gap should equal P->P baseline.
52+
53+
* bullet 1
54+
* bullet 2
55+
* bullet 3
56+
57+
Paragraph right after a UL. **Gap above** should equal "UL -> P".
58+
59+
Another paragraph. **Gap below** is "P -> UL" — currently larger than P->P.
60+
61+
* second list, item 1
62+
* second list, item 2
63+
64+
A paragraph. Then an OL:
65+
66+
1. first
67+
2. second
68+
69+
Paragraph after OL.
70+
71+
1. another OL
72+
2. another item
73+
74+
> A blockquote.
75+
76+
Paragraph after quote.
77+
78+
```
79+
fenced code block
80+
spans two lines
81+
```
82+
83+
Paragraph after code.
84+
85+
| col A | col B |
86+
|-------|-------|
87+
| 1 | 2 |
88+
| 3 | 4 |
89+
90+
Paragraph after table.
91+
92+
---
93+
94+
Paragraph after horizontal rule.
95+
""",
96+
97+
"C. header levels h1..h5": r"""
98+
Paragraph before H1.
99+
100+
# H1 heading
101+
102+
Paragraph after H1.
103+
104+
## H2 heading
105+
106+
Paragraph after H2.
107+
108+
### H3 heading
109+
110+
Paragraph after H3.
111+
112+
#### H4 heading
113+
114+
Paragraph after H4.
115+
116+
##### H5 heading
117+
118+
Paragraph after H5.
119+
120+
Paragraph between H5 and H1.
121+
122+
# Another H1
123+
124+
End paragraph.
125+
""",
126+
127+
"D. nested lists and adjacent lists": r"""
128+
Intro paragraph.
129+
130+
* outer 1
131+
* nested 1
132+
* nested 2
133+
* outer 2
134+
135+
Paragraph between two ULs.
136+
137+
- second UL item 1
138+
- second UL item 2
139+
140+
* third UL right after (no blank-line paragraph between)
141+
* third UL item 2
142+
143+
1. ordered after unordered
144+
2. ordered item 2
145+
146+
End paragraph.
147+
""",
148+
}
149+
150+
151+
def gui():
152+
for title, md in SECTIONS.items():
153+
if imgui.collapsing_header(title, imgui.TreeNodeFlags_.default_open.value):
154+
imgui_md.render(md)
155+
imgui.dummy(imgui.ImVec2(0, 12))
156+
157+
158+
def main():
159+
immapp.run(gui, with_markdown=True, window_size=(900, 1000), window_title="md gap diagnosis")
160+
161+
162+
if __name__ == "__main__":
163+
main()

external/imgui_md/imgui_md

0 commit comments

Comments
 (0)