Skip to content

Remove UseSoftlineBreakAsHardlineBreak from MarkdownParser #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/configure/content-set/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Example:

```yaml
project: 'PROJECT_NAME'
soft_line_endings: true

external_hosts:
- EXTERNAL_LINKS_HERE
Expand Down Expand Up @@ -41,6 +42,11 @@ Example:
project: 'APM Java agent reference'
```

### `soft_line_endings`

Optional key. Defaults to `false`. When enabled turns soft line endings in the markdown to hard HTML breaks `<br />`.


### `external_hosts`

All links to external hosts must be declared in this section of `docset.yml`.
Expand Down
4 changes: 4 additions & 0 deletions src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public record ConfigurationFile : DocumentationFile
private readonly int _depth;
public string? Project { get; }
public Glob[] Exclude { get; } = [];
public bool SoftLineEndings { get; }

public string[] CrossLinkRepositories { get; } = [];

Expand Down Expand Up @@ -68,6 +69,9 @@ public ConfigurationFile(IFileInfo sourceFile, IDirectoryInfo rootPath, BuildCon
case "project":
Project = reader.ReadString(entry.Entry);
break;
case "soft_line_endings":
SoftLineEndings = bool.TryParse(reader.ReadString(entry.Entry), out var softLineEndings) && softLineEndings;
break;
case "exclude":
Exclude = [.. YamlStreamReader.ReadStringArray(entry.Entry).Select(Glob.Parse)];
break;
Expand Down
1 change: 0 additions & 1 deletion src/Elastic.Markdown/Myst/MarkdownParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public MarkdownPipeline Pipeline
.UseDiagnosticLinks()
.UseHeadingsWithSlugs()
.UseEmphasisExtras(EmphasisExtraOptions.Default)
.UseSoftlineBreakAsHardlineBreak()
.UseSubstitution()
.UseComments()
.UseYamlFrontMatter()
Expand Down
6 changes: 3 additions & 3 deletions tests/Elastic.Markdown.Tests/Inline/SubstitutionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ not a comment
[Fact]
public void ReplacesSubsFromFrontMatter() =>
Html.Should().Contain(
"""Hello World!<br />"""
"""Hello World!"""
).And.Contain(
"""not a comment"""
)
Expand Down Expand Up @@ -52,7 +52,7 @@ not a {substitution}
[Fact]
public void PreservesSingleBracket() =>
Html.Should().Contain(
"""Hello World!<br />"""
"""Hello World!"""
).And.Contain(
"""not a comment"""
)
Expand Down Expand Up @@ -108,7 +108,7 @@ public class SupportsSubstitutionsFromDocSet(ITestOutputHelper output) : InlineT

[Fact]
public void EmitsGlobalVariable() =>
Html.Should().Contain("Hello World!<br />")
Html.Should().Contain("Hello World!")
.And.NotContain("{{hello-world}}")
.And.Contain("A variable from docset.yml")
.And.NotContain("{{global-var}}");
Expand Down
3 changes: 1 addition & 2 deletions tests/authoring/Container/DefinitionLists.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This is my `definition`
"""

[<Fact>]
let ``validate HTML 2`` () =
let ``validate HTML`` () =
markdown |> convertsToHtml """
<dl>
<dt>This is my
Expand All @@ -51,7 +51,6 @@ This is my `definition`
<dd>
<p>And this is the definition
<strong>body</strong>
<br>
Which may contain multiple lines
</p>
<div class="admonition note">
Expand Down
2 changes: 1 addition & 1 deletion tests/authoring/Inline/CrossLinksRedirects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type ``Scenario 2: Splitting a page into multiple smaller pages`` () =
[<Fact>]
let ``validate HTML`` () =
markdown |> convertsToHtml $"""
<p><a href="{urlPrefix}/testing/redirects/second-page#zz">Scenario 2</a><br/>
<p><a href="{urlPrefix}/testing/redirects/second-page#zz">Scenario 2</a>
<a href="{urlPrefix}/testing/redirects/third-page#bb">Scenario 2</a></p>
"""

Expand Down
8 changes: 4 additions & 4 deletions tests/authoring/Inline/Substitutions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ not a comment
[<Fact>]
let ``validate HTML: replace substitution`` () =
markdown |> convertsToHtml """
<p>The following should be subbed: Hello World!<br>
<p>The following should be subbed: Hello World!
not a comment</p>
"""

Expand All @@ -44,8 +44,8 @@ not a {substitution}
[<Fact>]
let ``validate HTML: leaves non subs alone`` () =
markdown |> convertsToHtml """
<p>The following should be subbed: Hello World!<br>
not a comment</br>
not a {{valid-key}}<br>
<p>The following should be subbed: Hello World!
not a comment
not a {{valid-key}}
not a {substitution}</p>
"""