Skip to content

Commit 689c4e5

Browse files
authored
Fix lists continuations. (#435)
* Fix lists continuations. List continuations that have blank lines are considered loose. As per commonmark spec these should render as paragraphs. `EnableTrackTrivia()` was breaking this behaviour. Validated we don't need triva for error message highlighting. * fix license header * fix tests * fix tests * fix test * Fix last failing test * Add test to ensure this fixes #405 too
1 parent 7ef1648 commit 689c4e5

File tree

9 files changed

+75
-16
lines changed

9 files changed

+75
-16
lines changed

docs/syntax/applies.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ Are equivalent, note `all` just means we won't be rendering the version portion
5252
## This section has its own applies annotations [#sections]
5353

5454
:::{applies}
55-
:stack: unavailable
56-
:serverless: tech-preview
57-
:cloud: ga
55+
:serverless: unavailable
5856
:::
5957

6058
:::{note}

src/Elastic.Markdown/Myst/Comments/CommentBlockParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public override bool Close(BlockProcessor processor, Block block)
155155
{
156156
if (!processor.TrackTrivia)
157157
{
158-
var heading = (HeadingBlock)block;
158+
var heading = (CommentBlock)block;
159159
heading.Lines.Trim();
160160
}
161161

src/Elastic.Markdown/Myst/MarkdownParser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public static MarkdownPipeline Pipeline
6060
return _pipeline;
6161

6262
var builder = new MarkdownPipelineBuilder()
63-
.EnableTrackTrivia()
6463
.UseInlineAnchors()
6564
.UsePreciseSourceLocation()
6665
.UseDiagnosticLinks()

tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ public class NestedDirectiveWithListTests(ITestOutputHelper output) : DirectiveT
120120
{
121121
[Fact]
122122
public void Render() => Html.Should().Contain("""
123-
<li> List Item 1
123+
<li>List Item 1
124124
<div class="admonition note">
125125
<p class="admonition-title">Note</p>
126-
Hello, World!
126+
Hello, World!
127127
</div>
128128
</li>
129129
""");
@@ -149,10 +149,10 @@ public class NestedDirectiveWithListTests2(ITestOutputHelper output) : Directive
149149
{
150150
[Fact]
151151
public void Render() => Html.Should().Contain("""
152-
<li> List Item 1
152+
<li>List Item 1
153153
<div class="admonition note">
154154
<p class="admonition-title">Note</p>
155-
Hello, World!
155+
Hello, World!
156156
</div>
157157
</li>
158158
""");
@@ -177,10 +177,10 @@ public class NestedDirectiveWithListTests3(ITestOutputHelper output) : Directive
177177
{
178178
[Fact]
179179
public void Render() => Html.Should().Contain("""
180-
<li> List Item 1
180+
<li>List Item 1
181181
<div class="admonition note">
182182
<p class="admonition-title">Note</p>
183-
Hello, World!
183+
Hello, World!
184184
</div>
185185
</li>
186186
""");
@@ -203,10 +203,10 @@ public class DirectiveInList(ITestOutputHelper output) : DirectiveTest<Admonitio
203203

204204
[Fact]
205205
public void Render() => Html.Should().Contain("""
206-
<li> List Item 1
206+
<li>List Item 1
207207
<div class="admonition note">
208208
<p class="admonition-title">Note</p>
209-
Hello, World!
209+
Hello, World!
210210
</div>
211211
</li>
212212
""");

tests/Elastic.Markdown.Tests/Inline/InlineAnchorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void GeneratesAttributesInHtml() =>
132132
// language=html
133133
Html.Should().Be(
134134
"""
135-
<section id="my-anchor"><h2>Hello world <a class="headerlink" href="#my-anchor" title="Link to this heading">¶</a>
135+
<section id="my-anchor"><h2>Hello world<a class="headerlink" href="#my-anchor" title="Link to this heading">¶</a>
136136
</h2>
137137
</section>
138138
""".TrimEnd()

tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ public void GeneratesHtml() =>
225225
Html.TrimEnd().Should().Be("""
226226
<p>Links:</p>
227227
<ul>
228-
<li> <a href="/testing/req.html">Special Requirements</a></li>
228+
<li><a href="/testing/req.html">Special Requirements</a></li>
229229
</ul>
230230
<ul>
231-
<li> <a href="/testing/req.html">Special Requirements</a></li>
231+
<li><a href="/testing/req.html">Special Requirements</a></li>
232232
</ul>
233233
""");
234234

tests/authoring/Blocks/Lists.fs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
module ``block elements``.``list elements``
5+
6+
open Xunit
7+
open authoring
8+
9+
type ``supports loose lists`` () =
10+
static let markdown = Setup.Markdown """
11+
* **Consumption-based billing**:
12+
13+
You pay for the actual product used, regardless of the application or use case. This is different from subscription-based billing models where customers pay a flat fee restricted by usage quotas, or one-time upfront payment billing models such as those used for on-prem software licenses.
14+
15+
You can purchase credits for a single or multi-year contract. Consumption is on demand, and every month we deduct from your balance based on your usage and contract terms. This allows you to seamlessly expand your usage to the full extent of your requirements and available budget, without any quotas or restrictions.
16+
"""
17+
18+
[<Fact>]
19+
let ``validate HTML: adds paragraphs`` () =
20+
markdown |> convertsToHtml """
21+
<ul>
22+
<li>
23+
<p>
24+
<strong>Consumption-based billing</strong>:</p>
25+
<p>You pay for the actual product used, regardless of the application or use case. This is different from subscription-based billing models where customers pay a flat fee restricted by usage quotas, or one-time upfront payment billing models such as those used for on-prem software licenses.</p>
26+
<p>You can purchase credits for a single or multi-year contract. Consumption is on demand, and every month we deduct from your balance based on your usage and contract terms. This allows you to seamlessly expand your usage to the full extent of your requirements and available budget, without any quotas or restrictions.</p>
27+
</li>
28+
</ul>
29+
"""
30+

tests/authoring/Container/DefinitionLists.fs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,34 @@ This is my `definition`
5757
"""
5858
[<Fact>]
5959
let ``has no errors 2`` () = markdown |> hasNoErrors
60+
61+
62+
63+
type ``preserves paragraphs`` () =
64+
65+
static let markdown = Setup.Markdown """
66+
Elastic Consumption Unit (ECU)
67+
: An ECU is a unit of aggregate consumption across multiple resources over time.
68+
69+
Each type of computing resource (capacity, data transfer, and snapshot) that you consume has its own unit of measure.
70+
71+
In order to aggregate consumption across different resource types, all resources are priced in ECU.
72+
73+
Check Using Elastic Consumption Units for billing for more details.
74+
"""
75+
76+
[<Fact>]
77+
let ``validate HTML 2`` () =
78+
markdown |> convertsToHtml """
79+
<dl>
80+
<dt>Elastic Consumption Unit (ECU)</dt>
81+
<dd>
82+
<p>An ECU is a unit of aggregate consumption across multiple resources over time.</p>
83+
<p>Each type of computing resource (capacity, data transfer, and snapshot) that you consume has its own unit of measure.</p>
84+
<p>In order to aggregate consumption across different resource types, all resources are priced in ECU.</p>
85+
<p>Check Using Elastic Consumption Units for billing for more details.</p>
86+
</dd>
87+
</dl>
88+
"""
89+
[<Fact>]
90+
let ``has no errors`` () = markdown |> hasNoErrors

tests/authoring/authoring.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
<ItemGroup>
4848
<Compile Include="Blocks\CodeBlocks\CodeBlocks.fs" />
49+
<Compile Include="Blocks\Lists.fs" />
4950
</ItemGroup>
5051

5152
</Project>

0 commit comments

Comments
 (0)