public void TestSimpleFlowedToText () { string expected = "This is some sample text that has been formatted " + "according to the format=flowed rules defined in rfc3676. " + "This text, once converted, should all be on a single line." + Environment.NewLine; string text = "This is some sample text that has been formatted " + Environment.NewLine + "according to the format=flowed rules defined in rfc3676. " + Environment.NewLine + "This text, once converted, should all be on a single line." + Environment.NewLine; var converter = new FlowedToText (); var result = converter.Convert (text); Assert.AreEqual (expected, result); }
public void TestQuotedFlowedToText () { string expected = "> Thou villainous ill-breeding spongy dizzy-eyed reeky elf-skinned pigeon-egg!" + Environment.NewLine + ">> Thou artless swag-bellied milk-livered dismal-dreaming idle-headed scut!" + Environment.NewLine + ">>> Thou errant folly-fallen spleeny reeling-ripe unmuzzled ratsbane!" + Environment.NewLine + ">>>> Henceforth, the coding style is to be strictly enforced, including the use of only upper case." + Environment.NewLine + ">>>>> I've noticed a lack of adherence to the coding styles, of late." + Environment.NewLine + ">>>>>> Any complaints?" + Environment.NewLine; string text = "> Thou villainous ill-breeding spongy dizzy-eyed " + Environment.NewLine + "> reeky elf-skinned pigeon-egg!" + Environment.NewLine + ">> Thou artless swag-bellied milk-livered " + Environment.NewLine + ">> dismal-dreaming idle-headed scut!" + Environment.NewLine + ">>> Thou errant folly-fallen spleeny reeling-ripe " + Environment.NewLine + ">>> unmuzzled ratsbane!" + Environment.NewLine + ">>>> Henceforth, the coding style is to be strictly " + Environment.NewLine + ">>>> enforced, including the use of only upper case." + Environment.NewLine + ">>>>> I've noticed a lack of adherence to the coding " + Environment.NewLine + ">>>>> styles, of late." + Environment.NewLine + ">>>>>> Any complaints?" + Environment.NewLine; var converter = new FlowedToText (); var result = converter.Convert (text); Assert.AreEqual (expected, result); }
internal static string GetText (TextPart text) { if (text.IsFlowed) { var converter = new FlowedToText (); string delsp; if (text.ContentType.Parameters.TryGetValue ("delsp", out delsp)) converter.DeleteSpace = delsp.ToLowerInvariant () == "yes"; return converter.Convert (text.Text); } return text.Text; }
protected override void VisitTextPart (TextPart entity) { string text; if (entity.IsHtml) { var converter = new HtmlToHtml { HtmlTagCallback = HtmlTagCallback }; text = converter.Convert (entity.Text); } else if (entity.IsFlowed) { var converter = new FlowedToText (); text = converter.Convert (entity.Text); text = QuoteText (text); } else { // quote the original message text text = QuoteText (entity.Text); } var part = new TextPart (entity.ContentType.MediaSubtype.ToLowerInvariant ()) { Text = text }; Push (part); }