public void FormatTwiceBasicScenario() { RtfFormatter formatter = new RtfFormatter(); string input = @"{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Symbol;}}{\pard Urbem Romam a principio reges habuere; libertatem et consulatum L. Brutus instituit. dictaturae ad tempus sumebantur; neque decemviralis potestas ultra biennium, neque tribunorum militum consulare ius diu valuit. \sa200 \par}{\pard Second paragraph. \par}}"; string expectedOutput = shortRtfFormatted; string output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); }
public void NonRtfText() { RtfFormatter formatter = new RtfFormatter(); string input = @"fsdfd"; string output = formatter.GetFormattedText(input); }
public void EscapedBracketsAreNotTreatedAsBlockBegining() { RtfFormatter formatter = new RtfFormatter(); string input = @"{\rtf{\pard\listtext \{0\}.}\par}}"; string expectedOutput = @"{\rtf {\pard\listtext \{0\}.} \par}}"; string output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); }
public void TextContainsBlocksWithoutCurlyBrackets() { RtfFormatter formatter = new RtfFormatter(); string input = @"{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Symbol;}}\pard First paragraph \sa200 \par{\pard Second paragraph. \par}}"; string expectedOutput = this.rtfParWithoutBracketsFormatted; string output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); }
public void TextAlreadyFormatted() { RtfFormatter formatter = new RtfFormatter(); string input = shortRtfFormatted; string expectedOutput = shortRtfFormatted; string output = formatter.GetFormattedText(input); Assert.AreEqual(expectedOutput, output); }
public void LongRtf() { RtfFormatter formatter = new RtfFormatter(); Stream stream = File.OpenRead(@"..\..\LongRtf.txt"); string input = ""; using (stream) { StreamReader reader = new StreamReader(stream); input = reader.ReadToEnd(); } string output = formatter.GetFormattedText(input); }
private static void FormatRtf() { IntPtr currentScint = PluginBase.GetCurrentScintilla(); ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint); string allText = scintillaGateway.GetAllText(); if (!IsTextRtf(allText)) { return; } string newText = rtfFormatter.GetFormattedText(allText); if (allText != newText) { scintillaGateway.SetText(newText); } }