This commit is contained in:
2020-04-29 20:36:58 +00:00
parent f9ec52df9d
commit d6ca437a00
4 changed files with 34 additions and 5 deletions

View File

@@ -39,9 +39,16 @@
<AssemblyOriginatorKeyFile>AyaNova.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.11.23.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>libs\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\3rdprtylibs\json.net.40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ReverseMarkdown">
<HintPath>libs\ReverseMarkdown.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />

View File

@@ -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;
}