diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b59fc8f..3f6aec5 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,6 +25,14 @@ "type": "npm", "script": "compile", "problemMatcher": [] + }, + { + "type": "typescript", + "tsconfig": "tsconfig.json", + "option": "watch", + "problemMatcher": [ + "$tsc-watch" + ] } ] } \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..f4766eb --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,13 @@ +**/*.ts +**/tsconfig.json +**/*.map +**/*.bak +*.vsix +.gitignore +.vscode/** +.vscode-test/** +tsconfig.json +package-lock.json +test/** +node_modules/** +typings/** \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 53439ca..7ca4b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Confluence Wiki Markup +## 0.1.2 + +* fix rendering of tag inside of code macro +* fix [noformat issue](https://github.com/denco/vscode-confluence-markup/issues/3) +* fix strikethrough and italic text +* add table rendering + ## 0.1.1 * fix simple link diff --git a/package.json b/package.json index 1ff751f..d1fb765 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "confluence-markup", "displayName": "Confluence markup", - "version": "0.1.1", + "version": "0.1.2", "publisher": "denco", "description": "Confluence markup language support for Visual Studio Code", "keywords": [ @@ -37,7 +37,7 @@ "onCommand:confluence.showPreviewToSide", "onLanguage:confluence" ], - "main": "./out/src/extension", + "main": "./out/extension", "contributes": { "languages": [ { @@ -116,13 +116,13 @@ "test": "npm run compile && node ./node_modules/vscode/bin/test" }, "devDependencies": { + "@types/mocha": "^2.2.42", + "@types/node": "^7.0.43", "eslint": "^4.15.0", "tslint": "^5.9.1", "typescript": "^2.6.1", - "vsce": "^1.35.0", - "vscode": "^1.1.6", - "@types/node": "^7.0.43", - "@types/mocha": "^2.2.42" + "vsce": "^1.37.6", + "vscode": "^1.1.6" }, "__metadata": { "publisherDisplayName": "denco" diff --git a/resources/css/confluence.css b/resources/css/confluence.css index 4a3bd05..eb988cb 100644 --- a/resources/css/confluence.css +++ b/resources/css/confluence.css @@ -47,6 +47,11 @@ blockquote { border-left: 5px solid; } +table, th, td { + border: 1px solid; + border-collapse: collapse; +} + pre > code { display: inline-block; width: 90%; diff --git a/src/markupParser.ts b/src/markupParser.ts index 0e7d39c..12bb4ac 100644 --- a/src/markupParser.ts +++ b/src/markupParser.ts @@ -35,11 +35,12 @@ export async function parseMarkup(sourceUri: vscode.Uri, sourceText: string) { //TODO: use Tokenazer instead of line loop var result = ''; - let listTag = ''; let codeTagFlag = 0; + let tableFlag = true; for (let entry of sourceText.split(/\n/gi)) { let tag = entry; + let html_tag = false; if (codeTagFlag == 0) { tag = tag.replace(/h(\d+)\.\s([^\n]+)/g, "$2"); @@ -71,14 +72,19 @@ export async function parseMarkup(sourceUri: vscode.Uri, sourceText: string) { tag = tag.replace(/\(x\)/g, '(cross)'); tag = tag.replace(/\(!\)/g, '(warning)'); - tag = tag.replace(/\[([^|]*)?\|?([^|]*)\]/g, function (m0, m1, m2) { - if ((m1.length !== 0) && (m2.length !== 0)) { - return "" + m1 + ""; - } else { - return "" + m1 + ""; - } - }); + tag = tag.replace(/\\\\/gi, '
'); + let re = /\[([^|]*)?\|?([^|]*)\]/g + if (tag.match(re)) { + tag = tag.replace(re, function (m0, m1, m2) { + if ((m1.length !== 0) && (m2.length !== 0)) { + return "" + m1 + ""; + } else { + return "" + m1 + ""; + } + }); + html_tag = true; + } //img let img = /!(.*)!/; let match = tag.match(img); @@ -86,12 +92,31 @@ export async function parseMarkup(sourceUri: vscode.Uri, sourceText: string) { tag = ''; } + //table + let tab_th_re = /\s*\|\|.*\|\|$/gi; + let tab_td_re = /\s*\|.*\|$/gi; + if (tag.match(tab_th_re)) { + tag = tag.replace(/^\|\|/, ''); + tag = tag.replace(/\|\|$/, ''); + tag = tag.replace(/\|\|/gi, ''); + tag = '' + tag + ''; + tableFlag = true; + } else if (tag.match(tab_td_re)) { + tag = tag.replace(/^\|/, ''); + tag = tag.replace(/\|/gi, '' + tag + ''; + tableFlag = true; + } } // code // online code tag - tag = tag.replace(/\{code[^\}]*\}(.*)\{code\}/, "
$1
"); - let re = /\{code.*\}/; + tag = tag.replace(/\{(noformat|code)[^\}]*\}(.*)\{(noformat|code)\}/, function (m0, m1, m2) { + return "
" + m2.replace(/
"; + }); + + let re = /\{[(code)|(noformat)].*\}/; let match = tag.match(re); if (match) { if (codeTagFlag === 0) { @@ -130,13 +155,26 @@ export async function parseMarkup(sourceUri: vscode.Uri, sourceText: string) { } tag = tag.replace(/\*([^\*]*)\*/g, "$1"); - tag = tag.replace(/\B-(\w*)-\B/g, "striket-hrough"); - } - if (tag === '
') {
-			result += tag;
+			if ((! html_tag) && (! tag.match('$1");
+				tag = tag.replace(/_([\w ]*)_/g, "$1");
+			}
 		} else {
-			result += tag + '
'; + if (tag !== '
'){
+				tag = tag.replace(/';
+			}
 		}
+
+		if (tag.match(/^s*$/)){
+			tag = '
'; + } + //close table + if (!tag.match(/<\/tr>$/)){ + tag = '
'); + tag = tag.replace(/\|$/, ''); + tag = '
' + tag; + tableFlag = false; + } + result += tag; + // console.log("PARSED:" + tag); } diff --git a/test/test.confluence b/test/test.confluence index 89441ba..a046746 100644 --- a/test/test.confluence +++ b/test/test.confluence @@ -1,3 +1,19 @@ + +h1. *Examples* + +---- +h2. *headers:* + +h1. Header 1 +h2. Header 2 +h3. Header 3 +h4. Header 4 +h5. Header 5 +h6. Header 6 + +---- +h2. *smiles:* + * :) smile :) * :( sad :( * :P tongue @@ -10,41 +26,34 @@ * (x) * (!) -examples: +---- +h2. *Links:* -Confluence: * [Mark Up|https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html#ConfluenceWikiMarkup-Headings] * [Storage Format|https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html] +* [html format|https://www.w3schools.com/html/html_formatting.asp] +* [test|https://ifl2014.github.io/submissions/ifl2014_submission_18.pdf] - -(!) - -// Confluence - -h1. Header 1 - -h2. Header 2 - -h3. Header 3 - -h4. Header 4 - -h5. Header 5 - - -h2. Text Effects +---- +h2. *text effects:* *strong* + *bold text* _emphasis_ -_italics_ : Thing{_}x_ + +_italics_ : Thing_x_ + +_italics with spaces_ ??citation?? \\ --del eted- \\ -+inserted+ \\ +-deleted- \\ +-deleted with spaces- \\ ++inserted+ \\ Text with ^superscript^ : kg/m^3^ + Text with ~subscript~ {{monospaced}} @@ -54,35 +63,57 @@ bq. Here's how you make a paragraph appear as a block quotation. {color:red}look ma, red text!{color} ---- +h2. *lists:* -:) - - -- Simple list +Squared list - one - two -* Simple list +Dotted list * one * tree * third +Numbered list +# one +#* borderStyle +#* dasddasd +# two +# :) + +---- +h2. *table:* ||heading 1||heading 2||heading 3|| |cell A1|cell A2|cell A3| |cell B1|cell B2|cell B3| +---- +h2. *code:* + +{code:language=xml|title=test} + + + +{code} -{code:language|title=title|borderStyle=solid} +{code:language=sh|title=title|borderStyle=solid} bash {code} +{code}code oneline{code} -# one -#* borderStyle -#* dasddasd -# two -# :) +---- +h2. *noformat:* + +{noformat} + + +{noformat} + +{noformat}noformat oneline{noformat} + +h1. Ende -h1. Ende \ No newline at end of file +_emphasis_ \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index a87e3a0..d4a02c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,19 @@ -{ - "compilerOptions": { - "moduleResolution": "node", - "module": "commonjs", - "target": "es5", - "outDir": "out", - "lib": [ - "es6" - ], - "sourceMap": true, - "rootDir": "." - }, - "exclude": [ - "node_modules", - ".vscode-test" -] -} +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "target": "es5", + "outDir": "out", + "lib": [ + "es6" + ], + "sourceMap": true, + "rootDir": "./src", + // "strict": true, + }, + "exclude": [ + "node_modules", + ".vscode-test", + "test" + ] +} \ No newline at end of file