Skip to content

Commit 8afe4d2

Browse files
committed
juledoc: update and fix group documentation line handling
1 parent b172f81 commit 8afe4d2

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

gen/markdown/markdown.jule

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ impl gen {
4747
match type ctx.Node {
4848
| doc::Separator:
4949
if *group != 0 {
50-
self.out.WriteStr("\n```\n")!
51-
*group = 0
50+
self.out.WriteStr("\n")!
5251
} else {
5352
self.out.WriteStr("\n\n")!
53+
indent = 0
5454
}
55-
indent = 0
5655
lastIsListItem = false
5756
lastIsSeparator = true
5857
continue
@@ -74,8 +73,15 @@ impl gen {
7473
*group = ctx.Indent
7574
self.out.WriteStr("```\n")!
7675
} else if *group != 0 {
77-
self.out.WriteStr("\n")!
78-
self.out.WriteStr(strings::Repeat("\t", ctx.Indent-*group))!
76+
// Indentation is lower than group indentation.
77+
// This is end fo the group.
78+
if *group > ctx.Indent {
79+
self.out.WriteStr("\n```\n")!
80+
*group = 0
81+
} else {
82+
self.out.WriteStr("\n")!
83+
self.out.WriteStr(strings::Repeat("\t", ctx.Indent-*group))!
84+
}
7985
}
8086
txt := doc::Text(ctx.Node)
8187
writeDocText(str(txt))
@@ -88,8 +94,15 @@ impl gen {
8894
self.out.WriteStr("<br>\n\n")!
8995
}
9096
} else if *group != 0 {
91-
self.out.WriteStr("\n")!
92-
self.out.WriteStr(strings::Repeat("\t", ctx.Indent-*group))!
97+
// Indentation is lower than group indentation.
98+
// This is end fo the group.
99+
if *group > ctx.Indent {
100+
self.out.WriteStr("\n```\n")!
101+
*group = 0
102+
} else {
103+
self.out.WriteStr("\n")!
104+
self.out.WriteStr(strings::Repeat("\t", ctx.Indent-*group))!
105+
}
93106
}
94107
self.out.WriteStr("- ")!
95108
txt := doc::ListItem(ctx.Node)

0 commit comments

Comments
 (0)