Skip to content
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

fix: Workaround a crash in parsing from an incorrect url span #336

Merged
merged 3 commits into from
Oct 7, 2024
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
2 changes: 1 addition & 1 deletion MarkdigPatches/MarkdigPatches.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Markdig" Version="0.33.0" />
<PackageReference Include="Markdig" Version="0.37.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Marksman/Marksman.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<PackageReference Include="FSharp.SystemCommandLine" Version="0.13.0-beta4"/>
<PackageReference Include="FSharpPlus" Version="1.5.0"/>
<PackageReference Include="Glob" Version="1.1.9"/>
<PackageReference Include="Markdig" Version="0.33.0"/>
<PackageReference Include="Markdig" Version="0.37.0"/>
<!-- <PackageReference Include="Ionide.LanguageServerProtocol" Version="0.3.1" />-->
<PackageReference Include="Serilog" Version="2.11.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1"/>
Expand Down
6 changes: 5 additions & 1 deletion Marksman/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ module Markdown =
let link = MdLink.RC label |> Node.mk linkText linkRange
elements.Add(ML link)
// The last remaining option is full reference
else
//
// NOTE: there's something off in Markdig's LinkHelper.TryParseLabelTrivia
// This is called from PatchedInlineLinkParser:341.
// TODO: Figure out why there's an incorrect urlSpan (-1 -- 0) returned.
else if not (String.IsNullOrEmpty url) then
let text_ = Node.mkText label (sourceSpanToRange text labelSpan)
let label = Node.mkText url (sourceSpanToRange text urlSpan)
let link = MdLink.RF(text_, label) |> Node.mk linkText linkRange
Expand Down
6 changes: 6 additions & 0 deletions Tests/ParserTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,9 @@ module RegressionTests =
" '00000758', '00000113', '00000152', '00000099', '00000932', '00000071', "
" '00000126', '00000450', '00000677', '00000722', '00000724', '00000182', "
" '00000507', '00000001', '00000866', '00000147', '00000186', '00000711' @ (2,0)-(7,70)" ]

[<Fact>]
let no334 () =
let content = "[][][]"
let actual = scrapeString content
checkInlineSnapshot actual []
Loading