Skip to content

Commit

Permalink
🎨 String.raw
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhang committed Dec 13, 2020
1 parent af918d4 commit 736d5d7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/tableFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ class MarkdownDocumentFormatter implements DocumentFormattingEditProvider {
}

private detectTables(text: string) {
const lineBreak = '\\r?\\n';
const contentLine = '\\|?.*\\|.*\\|?';
const lineBreak = String.raw`\r?\n`;
const contentLine = String.raw`\|?.*\|.*\|?`;

const leftSideHyphenComponent = '(?:\\|? *:?-+:? *\\|)';
const middleHyphenComponent = '(?: *:?-+:? *\\|)*';
const rightSideHyphenComponent = '(?: *:?-+:? *\\|?)'
const leftSideHyphenComponent = String.raw`(?:\|? *:?-+:? *\|)`;
const middleHyphenComponent = String.raw`(?: *:?-+:? *\|)*`;
const rightSideHyphenComponent = String.raw`(?: *:?-+:? *\|?)`;
const multiColumnHyphenLine = leftSideHyphenComponent + middleHyphenComponent + rightSideHyphenComponent;

//// GitHub issue #431
const singleColumnHyphenLine = '(?:\\| *:?-+:? *\\|)'
const singleColumnHyphenLine = String.raw`(?:\| *:?-+:? *\|)`;

const hyphenLine = '[ \\t]*(?:' + multiColumnHyphenLine + '|' + singleColumnHyphenLine + ')[ \\t]*';
const hyphenLine = String.raw`[ \t]*(?:${multiColumnHyphenLine}|${singleColumnHyphenLine})[ \t]*`;

const tableRegex = new RegExp(contentLine + lineBreak + hyphenLine + '(?:' + lineBreak + contentLine + ')*', 'g');
return text.match(tableRegex);
Expand Down

0 comments on commit 736d5d7

Please sign in to comment.