[parsing] Make URL parser not eat trailing parentheses
This commit is contained in:
parent
b705c95714
commit
ef226ee8fe
2 changed files with 24 additions and 17 deletions
|
@ -248,7 +248,7 @@ module private MfmParser =
|
||||||
|
|
||||||
let urlNodePlain =
|
let urlNodePlain =
|
||||||
lookAhead (skipString "https://" <|> skipString "http://")
|
lookAhead (skipString "https://" <|> skipString "http://")
|
||||||
>>. manyCharsTill anyChar (nextCharSatisfies isWhitespace <|> skipAnyOf "()" <|> eof) //FIXME: this needs significant improvements
|
>>. manyCharsTill anyChar (nextCharSatisfies isWhitespace <|> nextCharSatisfies (isAnyOf "()") <|> eof) //FIXME: this needs significant improvements
|
||||||
>>= fun uri ->
|
>>= fun uri ->
|
||||||
match Uri.TryCreate(uri, UriKind.Absolute) with
|
match Uri.TryCreate(uri, UriKind.Absolute) with
|
||||||
| true, finalUri ->
|
| true, finalUri ->
|
||||||
|
|
|
@ -81,12 +81,9 @@ public class MfmTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestInvalidMention()
|
public void TestInvalidMention()
|
||||||
{
|
{
|
||||||
const string input = "test @test@ test";
|
const string input = "test @test@ test";
|
||||||
List<MfmNode> expected =
|
List<MfmNode> expected = [new MfmTextNode("test @test@ test")];
|
||||||
[
|
var res = Mfm.parse(input);
|
||||||
new MfmTextNode("test @test@ test")
|
|
||||||
];
|
|
||||||
var res = Mfm.parse(input);
|
|
||||||
|
|
||||||
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
||||||
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||||
|
@ -126,11 +123,8 @@ public class MfmTests
|
||||||
```
|
```
|
||||||
""";
|
""";
|
||||||
|
|
||||||
List<MfmNode> expected =
|
List<MfmNode> expected = [new MfmCodeBlockNode("asd\nsdf", "cs")];
|
||||||
[
|
var res = Mfm.parse(input);
|
||||||
new MfmCodeBlockNode("asd\nsdf", "cs")
|
|
||||||
];
|
|
||||||
var res = Mfm.parse(input);
|
|
||||||
|
|
||||||
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
||||||
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||||
|
@ -159,6 +153,19 @@ public class MfmTests
|
||||||
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestUrl()
|
||||||
|
{
|
||||||
|
const string input = "https://example.org/path/Name_(test)_asdf";
|
||||||
|
//TODO: List<MfmNode> expected = [new MfmUrlNode(input, false),];
|
||||||
|
List<MfmNode> expected = [new MfmUrlNode(input[..30], false), new MfmTextNode(input[30..])];
|
||||||
|
var res = Mfm.parse(input);
|
||||||
|
|
||||||
|
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
||||||
|
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||||
|
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Benchmark()
|
public void Benchmark()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue