This commit is contained in:
@@ -15,6 +15,8 @@ using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
//using HtmlAgilityPack;
|
||||
//using ReverseMarkdown;
|
||||
|
||||
|
||||
namespace AyaNova.PlugIn.V8
|
||||
@@ -746,6 +748,7 @@ namespace AyaNova.PlugIn.V8
|
||||
|
||||
WikiPage w = WikiPage.GetItem(tid);
|
||||
var content = w.GetContentAsString;
|
||||
if (string.IsNullOrWhiteSpace(content)) return null;
|
||||
|
||||
//TODO: fixup internal urls using MAP of file attachment uploads
|
||||
|
||||
@@ -756,12 +759,31 @@ namespace AyaNova.PlugIn.V8
|
||||
content = content.Replace(m.Value, "<img src=\"" + "[ATTACH:" + RavenId.ToString() + "]" + "\">");
|
||||
}
|
||||
|
||||
//TODO: Convert to Markdown format
|
||||
//todo: fixup font size, try to convert to heading tags instead
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(content))
|
||||
return content;
|
||||
else
|
||||
return null;
|
||||
//TODO: Convert to Markdown format
|
||||
//found 2 likely candidate libs to do this
|
||||
//https://www.nuget.org/packages/Html2Markdown/
|
||||
//https://www.nuget.org/packages/ReverseMarkdown/
|
||||
|
||||
//Not much difference at first glance, very similar stats, reverse markdown is a little more widely used and seems to have more config options
|
||||
//built in, the other has to make some kind of processor for some stuff maybe so going with reverse for now
|
||||
|
||||
//NOTE: for this to work had to add an assembly redirect in app.config for ayanova project as it was looking for a really old version of
|
||||
//the HtmlAgilityPack
|
||||
|
||||
var config = new ReverseMarkdown.Config
|
||||
{
|
||||
UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.Bypass,
|
||||
GithubFlavored = true, // generate GitHub flavoured markdown, supported for BR, PRE and table tags
|
||||
RemoveComments = true, // will ignore all comments
|
||||
SmartHrefHandling = true // remove markdown output for links where appropriate
|
||||
};
|
||||
|
||||
var converter = new ReverseMarkdown.Converter(config);
|
||||
string res = converter.Convert(content);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user