feature: Add Quote Formatting (#1348)

* Implement Quote Formatting

Adds support for block quote text formatting. This feature is currently only implemented in the Canary client.
This formatting adds a "> " to each new line from the input text.

* add > char to character sanitization

* change assumptions around whitespace strings

* add blockquote (>>>) formatting + test
This commit is contained in:
Chris Johnston
2019-08-25 06:14:24 -07:00
committed by Christopher F
parent 52565ed0de
commit 265da99619
2 changed files with 86 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ namespace Discord
[InlineData(@"~text~", @"\~text\~")]
[InlineData(@"`text`", @"\`text\`")]
[InlineData(@"_text_", @"\_text\_")]
[InlineData(@"> text", @"\> text")]
public void Sanitize(string input, string expected)
{
Assert.Equal(expected, Format.Sanitize(input));
@@ -28,5 +29,35 @@ namespace Discord
Assert.Equal("```cs\ntest\n```", Format.Code("test", "cs"));
Assert.Equal("```cs\nanother\none\n```", Format.Code("another\none", "cs"));
}
[Fact]
public void QuoteNullString()
{
Assert.Null(Format.Quote(null));
}
[Theory]
[InlineData("", "")]
[InlineData("\n", "\n")]
[InlineData("foo\n\nbar", "> foo\n> \n> bar")]
[InlineData("input", "> input")] // single line
// should work with CR or CRLF
[InlineData("inb4\ngreentext", "> inb4\n> greentext")]
[InlineData("inb4\r\ngreentext", "> inb4\r\n> greentext")]
public void Quote(string input, string expected)
{
Assert.Equal(expected, Format.Quote(input));
}
[Theory]
[InlineData(null, null)]
[InlineData("", "")]
[InlineData("\n", "\n")]
[InlineData("foo\n\nbar", ">>> foo\n\nbar")]
[InlineData("input", ">>> input")] // single line
// should work with CR or CRLF
[InlineData("inb4\ngreentext", ">>> inb4\ngreentext")]
[InlineData("inb4\r\ngreentext", ">>> inb4\r\ngreentext")]
public void BlockQuote(string input, string expected)
{
Assert.Equal(expected, Format.BlockQuote(input));
}
}
}