-
Notifications
You must be signed in to change notification settings - Fork 872
/
Copy pathRtfBuildStep.cs
45 lines (37 loc) · 1.42 KB
/
RtfBuildStep.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace RtfDocumentProcessors
{
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Threading.Tasks;
using System.Threading.Tasks.Schedulers;
using MarkupConverter;
using Docfx.Plugins;
[Export(nameof(RtfDocumentProcessor), typeof(IDocumentBuildStep))]
public class RtfBuildStep : IDocumentBuildStep
{
#region Build
private readonly TaskFactory _taskFactory = new TaskFactory(new StaTaskScheduler(1));
public void Build(FileModel model, IHostService host)
{
string content = (string)((Dictionary<string, object>)model.Content)["conceptual"];
content = _taskFactory.StartNew(() => RtfToHtmlConverter.ConvertRtfToHtml(content)).Result;
((Dictionary<string, object>)model.Content)["conceptual"] = content;
}
#endregion
#region Others
public int BuildOrder => 0;
public string Name => nameof(RtfBuildStep);
public void Postbuild(ImmutableList<FileModel> models, IHostService host)
{
}
public IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host)
{
return models;
}
#endregion
}
}