[parsing] Fix silent link nodes

This commit is contained in:
Laura Hausmann 2024-11-21 16:52:24 +01:00
parent 718e67827e
commit b9be67302c
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 13 additions and 1 deletions

View file

@ -473,7 +473,7 @@ module private MfmParser =
| '<', Simple when stream.Match "<plain>" -> plainNode
| '\\', (Full | Inline) when stream.Match "\\(" -> mathNode
| '$', (Full | Inline) when stream.Match "$[" -> fnNode
| '?', (Full | Inline) when stream.Match "[" -> linkNode
| '?', (Full | Inline) when stream.Match "?[" -> linkNode
// Fallback to char node
| _ -> charNode
<| stream

View file

@ -368,6 +368,18 @@ public class MfmTests
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
}
[TestMethod]
public void TestLinkSilent()
{
const string input = "?[test](https://example.org/path/Name_(test)_asdf)";
List<MfmNode> expected = [new MfmLinkNode("https://example.org/path/Name_(test)_asdf", "test", true)];
var res = Mfm.parse(input);
AssertionOptions.FormattingOptions.MaxDepth = 100;
res.ToList().Should().Equal(expected, MfmNodeEqual);
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
}
[TestMethod]
public void TestLinkNeg()
{