Skip to content

Commit 5f81a0f

Browse files
authored
Merge pull request #40 from denco/fix/issues_37_38_39
Fix/issues 37 38 39
2 parents b21ee44 + 82950e2 commit 5f81a0f

File tree

13 files changed

+1160
-888
lines changed

13 files changed

+1160
-888
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Confluence Wiki Markup
22

3+
## [1.0.0](https://github.com/denco/vscode-confluence-markup/releases/tag/1.0.0)
4+
5+
- non preview release [1.0.0](https://github.com/denco/vscode-confluence-markup/issues/37)
6+
- fix render links inside of table [Preview is not working using links inside a table](https://github.com/denco/vscode-confluence-markup/issues/38)
7+
- fix render local images [Image preview](https://github.com/denco/vscode-confluence-markup/issues/39)
8+
- render image attributes
9+
310
## [0.1.12](https://github.com/denco/vscode-confluence-markup/releases/tag/0.1.12)
411

512
- fix monospace with digits [Monospaced Text does not seem to be supported](https://github.com/denco/vscode-confluence-markup/issues/34)

npm-shrinkwrap.json

Lines changed: 856 additions & 723 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "confluence-markup",
33
"displayName": "Confluence markup",
4-
"version": "0.1.12",
4+
"version": "1.0.0",
55
"publisher": "denco",
66
"description": "Confluence markup language support for Visual Studio Code",
77
"keywords": [
@@ -19,7 +19,7 @@
1919
"Programming Languages",
2020
"Snippets"
2121
],
22-
"preview": true,
22+
"preview": false,
2323
"repository": {
2424
"type": "git",
2525
"url": "https://github.com/denco/vscode-confluence-markup"
@@ -137,23 +137,23 @@
137137
"changelog": "if [ $((grep \"$(grep -m1 'version' package.json | cut -d '\"' -f 4)\" -n CHANGELOG.md || echo 0) | cut -d ':' -f 1) -eq 3 ]; then awk '/##/{++c;next} c==1' CHANGELOG.md | awk '!/^$/'; else >&2 echo 'Unchecked version'; exit 1; fi"
138138
},
139139
"devDependencies": {
140-
"@types/glob": "^7.1.1",
141-
"@types/mocha": "^8.2.2",
142-
"@types/node": "^14.14.37",
140+
"@types/glob": "^7.1.4",
141+
"@types/mocha": "^9.0.0",
142+
"@types/node": "^14.17.5",
143143
"@types/vscode": "^1.40.0",
144-
"@typescript-eslint/eslint-plugin": "^4.20.0",
145-
"@typescript-eslint/parser": "^4.20.0",
146-
"eslint": "^7.23.0",
147-
"glob": "^7.1.4",
144+
"@typescript-eslint/eslint-plugin": "^4.28.4",
145+
"@typescript-eslint/parser": "^4.28.4",
146+
"eslint": "^7.31.0",
147+
"glob": "^7.1.7",
148148
"html-formatter": "^0.1.9",
149-
"mocha": "^8.3.2",
150-
"ovsx": "^0.1.0-next.a9154dc",
149+
"mocha": "^9.0.2",
150+
"ovsx": "^0.2.0",
151151
"rimraf": "^3.0.2",
152152
"run-script-os": "^1.1.6",
153153
"source-map-support": "^0.5.12",
154-
"typescript": "^4.2.3",
154+
"typescript": "^4.3.5",
155155
"vsce": "^1.87.1",
156-
"vscode-test": "^1.5.2"
156+
"vscode-test": "^1.6.1"
157157
},
158158
"eslintConfig": {
159159
"env": {

src/markupParser.ts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ function imageUri(searchUri: vscode.Uri, imageLink: string) {
1414
if (imageLink.match(/^(ht)|(f)tps?:\/\//)) {
1515
imageUri = vscode.Uri.parse(imageLink);
1616
} else {
17-
imageUri = vscode.Uri.file(path.join(searchUri.fsPath, imageLink)).with({ scheme: 'vscode-resource' });
17+
if (path.isAbsolute(imageLink)) {
18+
imageUri = vscode.Uri.file(imageLink).with({ scheme: 'vscode-resource' });
19+
} else {
20+
imageUri = vscode.Uri.file(path.join(path.dirname(searchUri.fsPath), imageLink)).with({ scheme: 'vscode-resource' });
21+
}
1822
}
1923
return imageUri;
2024
}
@@ -112,27 +116,42 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
112116
html_tag = true;
113117
}
114118
//img
115-
const img_re = /!([^|]*)\|?.*!/;
119+
const img_re = /!([^|]*)\|?(.*)!/;
116120
const img_match = tag.match(img_re);
117121
if (img_match) {
118-
tag = '<img src="' + imageUri(sourceUri, img_match[1]) + '"/>';
122+
let imgAttr = ""
123+
if (img_match[2].length != 0){
124+
imgAttr = img_match[2].replace(/=/gi, '="').replace(/,/gi, '" ') + '"'
125+
}
126+
tag = `<img src="${imageUri(sourceUri, img_match[1])}" ${imgAttr}/>`;
119127
}
120128

121129
//Table
122130
const tab_th_re = /\s*[^{]*\|{2}[^}]*$/gi;
123131
const tab_td_re = /\s*[^{]*\|[^}]*$/gi;
124-
if (!html_tag && (tag.match(tab_th_re) || tag.match(tab_td_re))) {
125-
tag = tag.replace(/^\|{2,}/, '||');
126-
tag = tag.replace(/^\|{2}/, '<th>');
127-
tag = tag.replace(/\|{2}$/, '</th>');
128-
tag = tag.replace(/\|{2}/gi, '</th><th>');
129-
tag = tag.replace(/^\|/, '<td>');
130-
tag = tag.replace(/\|$/, '</td>');
131-
tag = tag.replace(/\|/gi, '</td><td>');
132-
if (tableFlag == false) {
133-
tag = '<table>' + tag;
132+
if ((tag.match(tab_th_re) || tag.match(tab_td_re))) {
133+
let closeTableCell = '';
134+
if (tag.match(tab_th_re)) {
135+
tag = tag.replace(/^\|{2,}/, '||');
136+
tag = tag.replace(/^\|{2}/, '<th>');
137+
tag = tag.replace(/\|{2}$/, '</th>');
138+
tag = tag.replace(/\|{2}/gi, '</th><th>');
139+
tag = tag.replace(/\|/, '</th><td>'); // row heading
140+
closeTableCell = '</th>';
141+
}
142+
if (tag.match(tab_td_re)) {
143+
tag = tag.replace(/^\|/, '<td>');
144+
tag = tag.replace(/\|$/, '</td>'); //.replace(/$/, '</td>');
145+
tag = tag.replace(/\|/gi, '</td><td>');
146+
closeTableCell = '</td>';
147+
}
148+
if (!tag.endsWith('</th>') && !tag.endsWith('</td>')){
149+
tag += closeTableCell;
134150
}
135151
tag = '<tr>' + tag + '</tr>';
152+
if (tableFlag == false) {
153+
tag = '<table><tbody>' + tag;
154+
}
136155
tableFlag = true;
137156
}
138157
}
@@ -238,7 +257,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
238257

239258
if (! codeTagFlag) {
240259
// lists
241-
const li_re = /^([-|*|#]+)\s(.*)/;
260+
const li_re = /^([-*#]+)\s(.*)/;
242261
const li_match = tag.match(li_re);
243262
if (li_match) {
244263
listFlag = true;
@@ -248,11 +267,11 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
248267
listTag = 'ol';
249268
// reset ol after 3rd level
250269
// add count of non-ol elements for mixed lists
251-
if ((li_match[1].length + (li_match[1].match(/[-|*]/g) || []).length) % 3 === 1) {
270+
if ((li_match[1].length + (li_match[1].match(/[-*]/g) || []).length) % 3 === 1) {
252271
listStyle = ' class="initial"';
253272
}
254273
}
255-
if (li_match[1].match(/[-|*]$/)) {
274+
if (li_match[1].match(/[-*]$/)) {
256275
listTag = 'ul';
257276
}
258277
if (li_match[1].match(/-$/)) {
@@ -298,10 +317,10 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
298317

299318
//close table
300319
if (!tag.match(/<\/tr>$/) && tableFlag) {
301-
tag = '</table>' + tag;
320+
tag = '</tbody></table>' + tag;
302321
tableFlag = false;
303322
}
304-
result += "<p>" + tag + "</p>";
323+
result += `<p>${tag}</p>`;
305324
}
306325

307326
return result;

src/test/suite/fixtures/expected/issues.html

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ <h1>
2323
<h4>Table without heading</h4>
2424
</p>
2525
<p>
26-
<tr>
27-
<table>
28-
<td>test</td>
29-
<td>test</td>
30-
</tr>
31-
</p>
32-
<p>
33-
<tr>
34-
<td>simple table</td>
35-
<td>two</td>
36-
</tr>
37-
</p>
38-
<p></table>
26+
<table>
27+
<tbody>
28+
<tr>
29+
<td>test</td>
30+
<td>test</td>
31+
</tr>
32+
</p>
33+
<p>
34+
<tr>
35+
<td>simple table</td>
36+
<td>two</td>
37+
</tr>
38+
</p>
39+
<p></tbody>
40+
</table>
3941
</p>
4042
<p>
4143
<a href='https://github.com/denco/vscode-confluence-markup/issues/6'>#6</a>: Intenting</p>
@@ -224,4 +226,52 @@ <h3>third header</h3>
224226
<p>h244000c8</p>
225227
<p>
226228
<code style='font-family: Menlo, Monaco, Consolas, monospace'>monospace</code>
227-
</p>
229+
</p>
230+
<p>
231+
<a href='https://github.com/denco/vscode-confluence-markup/issues/37'>#37</a>move out of preview</p>
232+
<p>move out of preview, and bump to version: 1.0.0</p>
233+
<p>
234+
<a href='https://github.com/denco/vscode-confluence-markup/issues/38'>#38</a>Preview is not working using links inside a table</p>
235+
<p>
236+
<table>
237+
<tbody>
238+
<tr>
239+
<th>heading 1</th>
240+
<th>heading 2</th>
241+
<th>heading 3</th>
242+
</tr>
243+
</p>
244+
<p>
245+
<tr>
246+
<td>cell A1</td>
247+
<td>cell A2</td>
248+
<td>cell A3</td>
249+
</tr>
250+
</p>
251+
<p>
252+
<tr>
253+
<td>cell B1</td>
254+
<td>cell B2</td>
255+
<td>cell B3</td>
256+
</tr>
257+
</p>
258+
<p>
259+
<tr>
260+
<td>
261+
<a href='www.example.com'>example</a>
262+
</td>
263+
<td>
264+
<a href='www.google.com'>google</a>
265+
</td>
266+
<td>
267+
<a href='https://code.visualstudio.com/'>vscode</a>
268+
</td>
269+
</tr>
270+
</p>
271+
<p></tbody>
272+
</table>
273+
</p>
274+
<p>
275+
<a href='https://github.com/denco/vscode-confluence-markup/issues/39'>#39</a>Local image preview</p>
276+
<p>
277+
<img src="vscode-resource:_TEST_EXTENSION_PATH_PLACEHOLDER_/src/test/suite/fixtures/testfiles/media/testing_cat.gif" width="500"/></p>

src/test/suite/fixtures/expected/scoped/images.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1>cats</h1>
88
</li>
99
</p>
1010
<p>
11-
<img src="https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif"/>
11+
<img src="https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif" title="coding_cat"/>
1212
</p>
1313
<p></ul>
1414
</p>
@@ -19,7 +19,18 @@ <h1>cats</h1>
1919
</li>
2020
</p>
2121
<p>
22-
<img src="https://media.giphy.com/media/mlvseq9yvZhba/giphy.gif"/>
22+
<img src="https://media.giphy.com/media/mlvseq9yvZhba/giphy.gif" />
23+
</p>
24+
<p></ul>
25+
</p>
26+
<p>
27+
<ul class="alternate">
28+
<li>
29+
<strong>testing cat</strong>
30+
</li>
31+
</p>
32+
<p>
33+
<img src="vscode-resource:_TEST_EXTENSION_PATH_PLACEHOLDER_/src/test/suite/fixtures/testfiles/media/testing_cat.gif" width="500" height="500"/>
2334
</p>
2435
<p></ul>
2536
</p>

0 commit comments

Comments
 (0)