[parsing] Fix hashtag detection (ISH-302)
This commit is contained in:
parent
bf26ed58ff
commit
69065ef1d7
2 changed files with 23 additions and 1 deletions
|
@ -243,7 +243,7 @@ module private MfmParser =
|
||||||
let hashtagNode =
|
let hashtagNode =
|
||||||
previousCharSatisfiesNot isNotWhitespace
|
previousCharSatisfiesNot isNotWhitespace
|
||||||
>>. skipChar '#'
|
>>. skipChar '#'
|
||||||
>>. many1CharsTill letter (nextCharSatisfies isWhitespace <|> eof)
|
>>. many1CharsTill letter (nextCharSatisfiesNot isLetter)
|
||||||
|>> fun h -> MfmHashtagNode(h) :> MfmNode
|
|>> fun h -> MfmHashtagNode(h) :> MfmNode
|
||||||
|
|
||||||
let urlNodePlain =
|
let urlNodePlain =
|
||||||
|
|
|
@ -136,6 +136,28 @@ public class MfmTests
|
||||||
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||||
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestHashtag()
|
||||||
|
{
|
||||||
|
const string input = "test #test #test's #test. test";
|
||||||
|
|
||||||
|
List<MfmNode> expected =
|
||||||
|
[
|
||||||
|
new MfmTextNode("test "),
|
||||||
|
new MfmHashtagNode("test"),
|
||||||
|
new MfmTextNode(" "),
|
||||||
|
new MfmHashtagNode("test"),
|
||||||
|
new MfmTextNode("'s "),
|
||||||
|
new MfmHashtagNode("test"),
|
||||||
|
new MfmTextNode(". test"),
|
||||||
|
];
|
||||||
|
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