-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathAppSettings.cs
122 lines (97 loc) · 4.54 KB
/
AppSettings.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using alxnbl.OneNoteMdExporter.Models;
using Microsoft.Extensions.Configuration;
namespace alxnbl.OneNoteMdExporter.Infrastructure
{
public class AppSettings
{
/*
* Export general settings
* */
/// <summary>
/// Maximum number of characters of a page title. Among this limit, title is contracted.
/// </summary>
public static int PageTitleMaxLength { get; set; } = 50;
/// <summary>
/// Add at the beginning of each page a YAML header that include Page metadata (cf https://assemble.io/docs/YAML-front-matter.html)
/// </summary>
public static bool AddFrontMatterHeader { get; set; } = true;
/// <summary>
/// Front Matter date format https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
/// </summary>
public static string FrontMatterDateFormat { get; set; } = "yyyy-MM-ddTHH:mm:ss";
/// <summary>
/// Length limit of Section and page name used in file and folder name. Reduce this value to avoid error of max file system file path
/// </summary>
public static int MdMaxFileLength { get; set; } = 50;
/// <summary>
/// How page hierarchies should be exported :
/// - HierarchyAsFolderTree : add folder tree to store pages
/// - HierarchyAsPageTitlePrefix : prefix page title with their parent / grand-parent page name
/// - IgnoreHierarchy : ignore page hierarchy
/// Apply to : Markdown Format
/// </summary>
public static PageHierarchyEnum ProcessingOfPageHierarchy { get; set; } = PageHierarchyEnum.HierarchyAsFolderTree;
/// <summary>
/// For MdExport with ProcessingOfPageHierarchy=hierarchyAsPageTitlePrefix, the separator to use to prefix md page file name
/// Ex: "_" value for "ParentPage_ChildPage.md"
/// </summary>
public static string PageHierarchyFileNamePrefixSeparator { get; set; } = "_";
/// <summary>
/// Copy DocX export of pages along md files, keep temporary OneNote notebook opened
/// </summary>
public static bool KeepOneNoteTempFiles { get; set; } = false;
/// <summary>
/// Where file attachments and image files should me stored ?
/// - RootFolder : in a single folder at the root of the export folder,
/// - PageParentFolder : in folders next to the md file
/// Apply to : Markdown Format
/// </summary>
public static ResourceFolderLocationEnum ResourceFolderLocation { get; set; } = ResourceFolderLocationEnum.RootFolder;
/// <summary>
/// Name of the resource folder where attachments and image files are stored
/// </summary>
public static string ResourceFolderName { get; set; } = "_resources";
/*
* Markdown rendering Settings
* */
/// <summary>
/// One of pandoc format https://pandoc.org/MANUAL.html#general-options
/// Rq: For Joplin "gfm" is recommended
/// </summary>
public static string PanDocMarkdownFormat { get; set; } = "gfm";
/// <summary>
/// Convert HTML IMG tag generated by PanDoc into markdown references
/// </summary>
public static bool PostProcessingMdImgRef { get; set; } = true;
/// <summary>
/// Remove undesired quotation blocks sometimes generated by PanDoc
/// </summary>
public static bool PostProcessingRemoveQuotationBlocks { get; set; } = true;
/// <summary>
/// Remove OneNote header generated by OneNote Export APIs
/// </summary>
public static bool PostProcessingRemoveOneNoteHeader { get; set; } = true;
/// <summary>
/// Replace every pair of linebreak by a single linebreak (to avoid duplicates generated by Pandoc)
/// </summary>
public static bool DeduplicateLinebreaks { get; set; } = true;
/// <summary>
/// Prevent generation of more that 2 linebreaks in a row
/// </summary>
public static bool MaxTwoLineBreaksInARow { get; set; } = true;
/*
* Developer Settings
* */
/// <summary>
/// Enable verbose mode and keep temporary files (.docx)
/// </summary>
public static bool Debug { get; set; } = false;
public static void LoadAppSettings()
{
new ConfigurationBuilder()
.AddJsonFile("appSettings.json")
.Build()
.Get<AppSettings>();
}
}
}