Skip to content

Commit f83f4a7

Browse files
authored
Merge pull request #51 from Excel-DNA/codex/add-utf-8-encoding-support
Add optional UTF-8 output support
2 parents b1cd90b + d744cf0 commit f83f4a7

File tree

16 files changed

+83
-26
lines changed

16 files changed

+83
-26
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,22 @@ that are exposed to Excel and documented using the ExcelFunctionAttribute and th
134134

135135
If The ExcelDna.Documentation library has been referenced then the ExcelFunctionDocAttribute
136136
is also available to include additional documentation fields that will not be exposed in the Excel Function
137-
Wizard, but will be included in the HTML Help Workshop content.
137+
Wizard, but will be included in the HTML Help Workshop content.
138+
139+
Build Properties
140+
----------------
141+
ExcelDnaDoc runs automatically when referenced via NuGet. Additional options
142+
can be configured by defining MSBuild properties in your project file.
143+
To enable UTF-8 output, add the following property:
144+
145+
```
146+
<ExcelDnaDocUseUtf8>true</ExcelDnaDocUseUtf8>
147+
```
138148

139149
Dependencies
140150
------------------
141-
NuGet Package Manager(http://nuget.codeplex.com/)
142-
FAKE (F# MAKE) (http://fsharp.github.io/FAKE/)
151+
NuGet Package Manager(http://nuget.codeplex.com/)
152+
FAKE (F# MAKE) (http://fsharp.github.io/FAKE/)
143153
Excel-DNA (http://exceldna.codeplex.com/)
144154
RazorEngine(https://github.com/Antaris/RazorEngine)
145155
HTML Help Workshop(http://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx / https://web.archive.org/web/20200918004813/https://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe)

docs/content/index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,21 @@ that are exposed to Excel and documented using the ExcelFunctionAttribute and th
134134

135135
If The ExcelDna.Documentation library has been referenced then the ExcelFunctionDocAttribute
136136
is also available to include additional documentation fields that will not be exposed in the Excel Function
137-
Wizard, but will be included in the HTML Help Workshop content.
137+
Wizard, but will be included in the HTML Help Workshop content.
138+
139+
Build Properties
140+
----------------
141+
ExcelDnaDoc runs automatically when referenced via NuGet. Additional options
142+
can be set through MSBuild properties in your project file. To generate
143+
UTF-8 encoded documentation add:
144+
145+
```
146+
<ExcelDnaDocUseUtf8>true</ExcelDnaDocUseUtf8>
147+
```
138148

139149
This Project Uses
140150
-----------------
141-
[Excel-DNA](http://exceldna.codeplex.com/)
151+
[Excel-DNA](http://exceldna.codeplex.com/)
142152
[FAKE (F# MAKE)](http://fsharp.github.io/FAKE/)
143153
[HTML Help Workshop ](http://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx)
144154
[NuGet Package Manager](http://nuget.codeplex.com/)

src/ExcelDnaDoc.Html/HelpContent/CategoryTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@model ExcelDna.Documentation.Models.CategoryModel
2+
@using ExcelDnaDoc
23
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34

45
<html>
56
<head>
7+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
68
<link rel="stylesheet" type="text/css" href="helpstyle.css">
79
<title></title>
810
</head>

src/ExcelDnaDoc.Html/HelpContent/CommandListTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@model ExcelDna.Documentation.Models.AddInModel
2+
@using ExcelDnaDoc
23
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34

45
<html>
56
<head>
7+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
68
<link rel="stylesheet" type="text/css" href="helpstyle.css">
79
<title></title>
810
</head>

src/ExcelDnaDoc.Html/HelpContent/CommandTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@model ExcelDna.Documentation.Models.CommandModel
2+
@using ExcelDnaDoc
23
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
34

45
<html>
56
<head>
7+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
68
<link rel="stylesheet" type="text/css" href="helpstyle.css">
79
<title></title>
810
</head>

src/ExcelDnaDoc.Html/HelpContent/FunctionTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@model ExcelDna.Documentation.Models.FunctionModel
2+
@using ExcelDnaDoc
23
@{
34
var parameters = new List<string>();
45
foreach (var p in Model.Parameters)
@@ -12,6 +13,7 @@
1213

1314
<html>
1415
<head>
16+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
1517
<link rel="stylesheet" type="text/css" href="helpstyle.css">
1618
<title></title>
1719
</head>

src/ExcelDnaDoc.Html/HelpContent/MethodListTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@model ExcelDna.Documentation.Models.AddInModel
2+
@using ExcelDnaDoc
23
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34

45
<html>
56
<head>
7+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
68
<link rel="stylesheet" type="text/css" href="helpstyle.css">
79
<title></title>
810
</head>

src/ExcelDnaDoc.Html/HelpContent/ProjectFileTemplate.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@model ExcelDna.Documentation.Models.AddInModel
22
@using System.Text;
3+
@using ExcelDnaDoc
34
@using System.Linq;
45
@{ var functions = Model.Functions.Where(f => f.TopicId != string.Empty);
56
var commands = Model.Commands.Where(c => c.TopicId != string.Empty);
@@ -22,7 +23,7 @@ Compiled file="@(Model.DnaFileName).chm"
2223
Contents file=Table of Contents.hhc
2324
Default topic=index.htm
2425
Display compile progress=No
25-
Language=0x409 English (United States)
26+
@if (HtmlHelp.UseUtf8Encoding) { "Code page=65001" } else { "Language=0x409 English (United States)" }
2627

2728
[INFOTYPES]
2829

src/ExcelDnaDoc.Html/HelpContent/TableOfContentsTemplate.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@model ExcelDna.Documentation.Models.AddInModel
2+
@using ExcelDnaDoc
23
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
34
<html>
45
<head>
6+
@if (HtmlHelp.UseUtf8Encoding) { <meta charset="utf-8"> }
57
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
68
<!-- Sitemap 1.0 -->
79
</head>

src/ExcelDnaDoc.Html/HtmlHelp.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using System.Linq;
8+
using System.Text;
89
using System.Threading.Tasks;
910
using ExcelDna.Documentation.Models;
1011
using ExcelDnaDoc.Templates;
@@ -14,11 +15,13 @@ public static class HtmlHelp
1415
public static string BuildFolderPath { get; set; }
1516
public static string HelpContentSourcePath { get; set; }
1617
public static string HelpContentFolderPath { get; set; }
18+
public static bool UseUtf8Encoding { get; private set; }
1719
public static ConcurrentDictionary<string, string> TemplateCache = new ConcurrentDictionary<string, string>();
1820

19-
public static void Create(AddInModel addin, string buildFolderPath, string outputFileName, string helpContentSourcePath = null, string hhcPath = null, string helpSubfolder = "HelpContent", bool excludeHidden = false, bool skipCompile = false, bool runAsync = false)
21+
public static void Create(AddInModel addin, string buildFolderPath, string outputFileName, string helpContentSourcePath = null, string hhcPath = null, string helpSubfolder = "HelpContent", bool excludeHidden = false, bool skipCompile = false, bool runAsync = false, bool useUtf8Encoding = false)
2022
{
2123
BuildFolderPath = buildFolderPath;
24+
UseUtf8Encoding = useUtf8Encoding;
2225
HelpContentFolderPath = Path.Combine(HtmlHelp.BuildFolderPath, helpSubfolder);
2326
HelpContentSourcePath = helpContentSourcePath ?? HelpContentFolderPath;
2427

@@ -80,7 +83,10 @@ public static void Create(AddInModel addin, string buildFolderPath, string outpu
8083
}
8184
if (!File.Exists(stylePath))
8285
{
83-
File.WriteAllText(stylePath, Properties.Resources.helpstyle);
86+
if (UseUtf8Encoding)
87+
File.WriteAllText(stylePath, Properties.Resources.helpstyle, Encoding.UTF8);
88+
else
89+
File.WriteAllText(stylePath, Properties.Resources.helpstyle);
8490
}
8591
else
8692
{

0 commit comments

Comments
 (0)