mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Escaping of '<' characters in Word to Markdown conversions
This commit is contained in:
@@ -37,13 +37,13 @@ function convertDocumentToMarkdown(doc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function findReplace(findText, findProps, replaceText, replaceProps) {
|
||||
function findReplace(findText, findOptions, replaceText, replaceOptions) {
|
||||
var find = doc.range().find;
|
||||
find.clearFormatting();
|
||||
setProperties(find, findProps);
|
||||
setProperties(find, findOptions);
|
||||
var replace = find.replacement;
|
||||
replace.clearFormatting();
|
||||
setProperties(replace, replaceProps);
|
||||
setProperties(replace, replaceOptions);
|
||||
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
|
||||
}
|
||||
function write(s) {
|
||||
@@ -162,6 +162,10 @@ function convertDocumentToMarkdown(doc) {
|
||||
}
|
||||
writeBlockEnd();
|
||||
}
|
||||
findReplace("<", {}, "<", {});
|
||||
findReplace("<", { style: "Code" }, "<", {});
|
||||
findReplace("<", { style: "Code Fragment" }, "<", {});
|
||||
findReplace("<", { style: "Terminal" }, "<", {});
|
||||
findReplace("", { font: { subscript: true } }, "<sub>^&</sub>", { font: { subscript: false } });
|
||||
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ });
|
||||
findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */ });
|
||||
|
||||
@@ -129,6 +129,15 @@ var sys = (function () {
|
||||
};
|
||||
})();
|
||||
|
||||
interface FindReplaceOptions {
|
||||
style?: any;
|
||||
font?: {
|
||||
bold?: boolean;
|
||||
italic?: boolean;
|
||||
subscript?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
function convertDocumentToMarkdown(doc: Word.Document): string {
|
||||
|
||||
var result: string = "";
|
||||
@@ -152,13 +161,13 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
|
||||
}
|
||||
}
|
||||
|
||||
function findReplace(findText: string, findProps: {}, replaceText: string, replaceProps: {}) {
|
||||
function findReplace(findText: string, findOptions: FindReplaceOptions, replaceText: string, replaceOptions: FindReplaceOptions) {
|
||||
var find = doc.range().find;
|
||||
find.clearFormatting();
|
||||
setProperties(find, findProps);
|
||||
setProperties(find, findOptions);
|
||||
var replace = find.replacement;
|
||||
replace.clearFormatting();
|
||||
setProperties(replace, replaceProps);
|
||||
setProperties(replace, replaceOptions);
|
||||
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
|
||||
}
|
||||
|
||||
@@ -295,6 +304,10 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
|
||||
writeBlockEnd();
|
||||
}
|
||||
|
||||
findReplace("<", {}, "<", {});
|
||||
findReplace("<", { style: "Code" }, "<", {});
|
||||
findReplace("<", { style: "Code Fragment" }, "<", {});
|
||||
findReplace("<", { style: "Terminal" }, "<", {});
|
||||
findReplace("", { font: { subscript: true } }, "<sub>^&</sub>", { font: { subscript: false } });
|
||||
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ });
|
||||
findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */});
|
||||
|
||||
Reference in New Issue
Block a user