Guest User

Untitled

a guest
Jun 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();
  2. h.OutputFormat = HtmlToRtf.eOutputFormat.TextUnicode;
  3. string text = h.ConvertString(htmlString);
  4.  
  5. public static string StripHTML(string HTMLText)
  6. {
  7. Regex reg = new Regex("<[^>]+>", RegexOptions.IgnoreCase);
  8. return reg.Replace(HTMLText, "");
  9. }
  10.  
  11. IHTMLDocument2 htmlDoc = (IHTMLDocument2)webBrowser.Document;
  12. string innerHTML = htmlDoc.body.innerHTML;
  13. string innerText = htmlDoc.body.innerText;
  14.  
  15. public static string ToMarkDown(this string input)
  16. {
  17. var process = new Process();
  18.  
  19. process.StartInfo = new ProcessStartInfo("python", "tools/html2text.py")
  20. {
  21. RedirectStandardInput = true,
  22. RedirectStandardOutput = true,
  23. UseShellExecute = false,
  24. CreateNoWindow = true,
  25. };
  26.  
  27. process.Start();
  28.  
  29. process.StandardInput.Write(input);
  30. process.StandardInput.Close();
  31.  
  32. string md = process.StandardOutput.ReadToEnd();
  33.  
  34. process.WaitForExit();
  35.  
  36. process.Dispose();
  37.  
  38. return md;
  39. }
  40.  
  41. using System;
  42. using System.Text.RegularExpressions;
  43.  
  44. public static class StringHelpers
  45. {
  46. public static string StripHTML(this string HTMLText)
  47. {
  48. var reg = new Regex("<[^>]+>", RegexOptions.IgnoreCase);
  49. return reg.Replace(HTMLText, "");
  50. }
  51. }
  52.  
  53. var yourHtmlString = "<div class="someclass"><h2>yourHtmlText</h2></span>";
  54. var yourTextString = yourHtmlString.StripHTML();
Add Comment
Please, Sign In to add comment