void RenderText (TextPart text)
		{
			string html;

			if (text.IsHtml) {
				// the text content is already in HTML format
				html = text.Text;
			} else if (text.IsFlowed) {
				var converter = new FlowedToHtml ();
				string delsp;

				// the delsp parameter specifies whether or not to delete spaces at the end of flowed lines
				if (!text.ContentType.Parameters.TryGetValue ("delsp", out delsp))
					delsp = "no";

				if (string.Compare (delsp, "yes", StringComparison.OrdinalIgnoreCase) == 0)
					converter.DeleteSpace = true;

				html = converter.Convert (text.Text);
			} else {
				html = new TextToHtml ().Convert (text.Text);
			}

			webView.LoadHtmlString (html, new NSUrl ("index.html"));
		}
Exemplo n.º 2
0
		public void TestBrokenQuotedFlowedToHtml ()
		{
			// Note: this is the brokenly quoted sample from rfc3676 at the end of section 4.5
			string expected = "<blockquote><p>Thou villainous ill-breeding spongy dizzy-eyed reeky elf-skinned pigeon-egg! </p>" + Environment.NewLine +
				"<blockquote><p>Thou artless swag-bellied milk-livered dismal-dreaming idle-headed scut!</p>" + Environment.NewLine +
				"<blockquote><p>Thou errant folly-fallen spleeny reeling-ripe unmuzzled ratsbane!</p>" + Environment.NewLine +
				"<blockquote><p>Henceforth, the coding style is to be strictly enforced, including the use of only upper case.</p>" + Environment.NewLine +
				"<blockquote><p>I&#39;ve noticed a lack of adherence to the coding styles, of late.</p>" + Environment.NewLine +
				"<blockquote><p>Any complaints?</p>" + Environment.NewLine +
				"</blockquote></blockquote></blockquote></blockquote></blockquote></blockquote>";
			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 FlowedToHtml ();
			var result = converter.Convert (text);

			Assert.AreEqual (expected, result);
		}
Exemplo n.º 3
0
		public void TestSimpleFlowedWithUrlsToHtml ()
		{
			string expected = "<p>Check out <a href=\"http://www.xamarin.com\">http://www.xamarin.com</a> - it&#39;s amazing!</p>" + Environment.NewLine;
			string text = "Check out http://www.xamarin.com - it's amazing!" + Environment.NewLine;
			var converter = new FlowedToHtml ();
			var result = converter.Convert (text);

			Assert.AreEqual (expected, result);
		}
Exemplo n.º 4
0
		public void TestSimpleFlowedToHtml ()
		{
			string expected = "<p>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.</p>" + Environment.NewLine +
				"<br/>" + Environment.NewLine +
				"<br/>" + Environment.NewLine +
				"<br/>" + Environment.NewLine +
				"<br/>" + Environment.NewLine +
				"<p>And this line of text should be separate by 4 blank lines.</p>" + 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 +
				Environment.NewLine +
				Environment.NewLine +
				Environment.NewLine +
				Environment.NewLine +
				"And this line of text should be separate by 4 blank lines." + Environment.NewLine;
			var converter = new FlowedToHtml ();
			var result = converter.Convert (text);

			Assert.AreEqual (expected, result);
		}