Skip to content

Instantly share code, notes, and snippets.

@michaelhidalgo
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save michaelhidalgo/6f6c1c2c80c586fb7b84 to your computer and use it in GitHub Desktop.

Select an option

Save michaelhidalgo/6f6c1c2c80c586fb7b84 to your computer and use it in GitHub Desktop.
WikiText issue.
var url = @"https://vulnerabilities.teammentor.net/html/c4914e51-2609-4edc-8133-31491f1b03c0";
string response;
using(var client = new WebClient())
{
response = client.DownloadString(url);
}
if (String.IsNullOrEmpty(response)) return;
response = response.Replace("<HEAD>",string.Format("<HEAD><base href='{0}' target='_blank'>",
@"https://vulnerabilities.teammentor.net"));
var doc = new HtmlDocument {OptionUseIdAttribute = true};
doc.LoadHtml(response);
var parser = new CreoleParser();
var transformedHtml =parser.Parse(doc.GetElementbyId("rawContent")
.InnerHtml);
doc.GetElementbyId("guidanceItem").InnerHtml = transformedHtml;
//Removing scripts and rawContent .
doc.DocumentNode.Descendants()
.Where(n => n.Name == "script" || n.Id == "rawContent")
.ToList()
.ForEach(n => n.Remove());
var rawHtml = doc.DocumentNode.OuterHtml;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment