Skip to content

Commit

Permalink
fixed issue with list rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraku committed Oct 14, 2024
1 parent 13d5268 commit f2a5aaf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
3 changes: 2 additions & 1 deletion documentation/NEXT_RELEASENOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- fixed StackOverflowException when using cyclic inheritdoc (fixes #142)
- fixed property getter/setter access modifier not taken into account (fixes #151)
- fixed markdown special characters not escaped (fixes #117)
- fixed unhandled xml elements not rendering as is in markdown (fixes #126)
- fixed unhandled xml elements not rendering as is in markdown (fixes #126)
- fixed issue with list rendering
4 changes: 2 additions & 2 deletions source/DefaultDocumentation.Markdown/Elements/ListElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ private static void WriteTable(IWriter writer, XElement element)
.Append("|");
}
}

writer.EnsureLineStartAndAppendLine();
}
}

Expand Down Expand Up @@ -142,6 +140,8 @@ public void Write(IWriter writer, XElement element)
WriteTable(writer, element);
break;
}

writer.EnsureLineStart();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public void NotWriteWhenTypeIsTableAndDisplayAsSingleLine() => Test(
public void WriteWhenTypeIsBullet() => Test(
new XElement("list", new XAttribute("type", "bullet"), new XElement("item", "item1"), new XElement("item", "item2")),
@"- item1
- item2");
- item2
");

[Fact]
public void WriteWhenNested() => Test(
Expand All @@ -56,13 +57,14 @@ public void WriteWhenNested() => Test(
- item2
1. item3
2. item4
- item5");
- item5
");

[Fact]
public void SeparateTermAndDescription() => Test(
new XElement("list", new XAttribute("type", "bullet"), new XElement("item", new XElement("term", "Term"), new XElement("description", "Description"))),
"- Term — Description"
);
@"- Term — Description
");

[Fact]
public void NotSeparateLonelyDescriptionAndTerm() => Test(
Expand All @@ -71,44 +73,49 @@ public void NotSeparateLonelyDescriptionAndTerm() => Test(
new XElement("item", new XElement("description", "Description"))
),
@"- Term
- Description"
);
- Description
");

[Fact]
public void WritePrefixWhenTypeIsBulletAndItemIsMultiline() => Test(
new XElement("list", new XAttribute("type", "bullet"), new XElement("item", "item1\nect..."), new XElement("item", "item2")),
@"- item1
ect...
- item2");
- item2
");

[Fact]
public void WriteNewlineWhenNeededAndTypeIsBullet() => Test(
w => w.Append("pouet"),
new XElement("list", new XAttribute("type", "bullet"), new XElement("item", "item1"), new XElement("item", "item2")),
@"pouet
- item1
- item2");
- item2
");

[Fact]
public void WriteWhenTypeIsNumber() => Test(
new XElement("list", new XAttribute("type", "number"), new XElement("item", "item1"), new XElement("item", "item2")),
@"1. item1
2. item2");
2. item2
");

[Fact]
public void WritePrefixWhenTypeIsNumberAndItemIsMultiline() => Test(
new XElement("list", new XAttribute("type", "number"), new XElement("item", "item1\nect..."), new XElement("item", "item2")),
@"1. item1
ect...
2. item2");
2. item2
");

[Fact]
public void WriteNewlineWhenNeededAndTypeIsNumber() => Test(
w => w.Append("pouet"),
new XElement("list", new XAttribute("type", "number"), new XElement("item", "item1"), new XElement("item", "item2")),
@"pouet
1. item1
2. item2");
2. item2
");

[Fact]
public void WriteWhenTypeIsTable() => Test(
Expand All @@ -120,7 +127,6 @@ public void WriteWhenTypeIsTable() => Test(
|-|-|
|item11|item12|
|item21|item22|
");

[Fact]
Expand All @@ -134,7 +140,6 @@ public void WritePrefixWhenTypeIsTableAndItemIsMultiline() => Test(
|-|-|
|item11<br/>ect...|item12|
|item21|item22|
");

[Fact]
Expand All @@ -150,6 +155,5 @@ public void WriteNewlineWhenNeededAndTypeIsTable() => Test(
|-|-|
|item11|item12|
|item21|item22|
");
}

0 comments on commit f2a5aaf

Please sign in to comment.