Skip to content

Commit b6a2a68

Browse files
committed
code cleanup, add render in word italics
1 parent 0e1b39f commit b6a2a68

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/markupParser.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
7979
if (!codeTagFlag) {
8080
tag = tag.replace(/h(\d+)\.\s([^\r?\n]+)/g, "<h$1>$2</h$1>");
8181

82-
// tag = tag.replace(/_([^_]*)_/g, "<em>$1</em>");
8382
tag = tag.replace(/\+([^+]*)\+/g, "<u>$1</u>");
8483
tag = tag.replace(/\^([^^]*)\^/g, "<sup>$1</sup>");
8584
tag = tag.replace(/~([^~]*)~/g, "<sub>$1</sub>");
@@ -307,7 +306,6 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
307306
}
308307
}
309308

310-
// if (! codeTagFlag) {
311309
// lists
312310
const li_re = /^([-*#]+)\s(.*)/;
313311
const li_match = tag.match(li_re);
@@ -337,13 +335,9 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
337335
tag = '</' + listArr.slice(li_match[1].length, listArr.length).reverse().join('></') + '>';
338336
listArr = listArr.slice(0, li_match[1].length);
339337
}
340-
// // This prevents the closing </li> tag from being added too prematurely.
341-
// if (codeTagFlag || panelTagFlag) {
338+
// This prevents the closing </li> tag from being added too prematurely.
339+
// ToDo: lists are 'open', means not all tags are closed
342340
tag += "<li>" + li_match[2];
343-
// } else {
344-
// // tag += "<li>" + li_match[2] + "</li>";
345-
// tag += "<li>" + li_match[2];
346-
// }
347341
}
348342

349343

@@ -363,19 +357,16 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
363357

364358
// strong
365359
tag = tag.replace(/\*([^*]*)\*/g, "<strong>$1</strong>");
366-
// line-through
360+
361+
// line-through and italic
367362
if ((!html_tag) && (!tag.match('<img')) && (!listFlag)) {
368363
// tag = tag.replace(/\B-([^-]*)-\B/g, " <span style='text-decoration: line-through;'>$1</span> ");
369-
// tag = tag.replace(/_([^_]*)_/g, "<i>$1</i>");
364+
// special case: in word italic
365+
// s. https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-TextEffects
366+
tag = tag.replace(/{_}([^_]*)_/g, "<i>$1</i>");
370367
tag = tag.replace(/\B-((\([^)]*\)|{[^}]*}|\[[^]]+\]){0,3})(\S.*?\S|\S)-\B/g, " <span style='text-decoration: line-through;'>$3</span> ");
371368
tag = tag.replace(/(?:\b)_((\([^)]*\)|{[^}]*}|\[[^]]+\]){0,3})(\S.*?\S|\S)_(?:\b)/g, "<i>$3</i>");
372369
}
373-
// This only really applied to the inner part of code blocks and noformat blocks, so I moved it there and used a flag to trigger it.
374-
// } else {
375-
// if (tag !== `<pre><code style='font-family: ${MONOSPACE_FONT_FAMILY}'>`) {
376-
// tag = tag.replace(/</gi, '&lt;') + '<br />';
377-
// }
378-
// }
379370

380371
//close table
381372
if (!tag.match(/<\/tr>$/) && tableFlag) {

0 commit comments

Comments
 (0)