Skip to content

Commit 201a0d8

Browse files
authored
Merge pull request #21 from denco/0.1.8
0.1.8
2 parents 56ab07d + 966a646 commit 201a0d8

File tree

18 files changed

+1037
-43
lines changed

18 files changed

+1037
-43
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"configurations": [
55
{
6-
"name": "Debug extension Extension",
6+
"name": "Debug extension",
77
"type": "extensionHost",
88
"request": "launch",
99
"runtimeExecutable": "${execPath}",

CHANGELOG.md

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

3+
## [0.1.8](https://github.com/denco/vscode-confluence-markup/releases/tag/0.1.8)
4+
5+
- fix [Multiply inline monospace macro](https://github.com/denco/vscode-confluence-markup/issues/17)
6+
- fix [Italic with dot at the end](https://github.com/denco/vscode-confluence-markup/issues/18)
7+
- fix rendering striked-throu markup
8+
- adjust content security policy
9+
- add downloads badge in [README.MD](https://github.com/denco/vscode-confluence-markup/blob/master/README.md)
10+
311
## [0.1.7](https://github.com/denco/vscode-confluence-markup/releases/tag/0.1.7)
412

513
- fix skip empty lines

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![The MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/denco/vscode-confluence-markup/blob/master/LICENSE)
44
[![Version](https://vsmarketplacebadge.apphb.com/version-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
55
[![Installs](https://vsmarketplacebadge.apphb.com/installs-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
6+
[![Downloads](https://vsmarketplacebadge.apphb.com/downloads-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
67
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
78

89
## Description

package.json

Lines changed: 5 additions & 5 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.7",
4+
"version": "0.1.8",
55
"publisher": "denco",
66
"description": "Confluence markup language support for Visual Studio Code",
77
"keywords": [
@@ -30,7 +30,7 @@
3030
"license": "MIT",
3131
"homepage": "https://github.com/denco/vscode-confluence-markup/blob/master/README.md",
3232
"engines": {
33-
"vscode": "^1.25.0"
33+
"vscode": "^1.40.0"
3434
},
3535
"activationEvents": [
3636
"onCommand:confluence.showPreview",
@@ -132,12 +132,12 @@
132132
},
133133
"devDependencies": {
134134
"@types/mocha": "^5.2.7",
135-
"@types/node": "^11.13.9",
136-
"eslint": "^5.16.0",
135+
"@types/node": "^12.12.7",
137136
"tslint": "^5.18.0",
138137
"typescript": "^3.5.3",
139138
"vsce": "^1.66.0",
140-
"vscode": "^1.1.36"
139+
"vscode": "^1.1.36",
140+
"html-formatter": "^0.1.9"
141141
},
142142
"__metadata": {
143143
"publisherDisplayName": "denco"

src/ConfluenceContentProvider.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Import the module and reference it with the alias vscode in your code below
44
import * as vscode from 'vscode';
55

6-
import { parseMarkup, cssUri } from './markupParser';
6+
import {parseMarkup} from './markupParser';
77

88
export function packConfluenceUri(uri: vscode.Uri) {
99
// Temporarily change the URI scheme
@@ -40,24 +40,10 @@ export class ConfluenceContentProvider implements vscode.TextDocumentContentProv
4040
}
4141

4242
public async provideTextDocumentContent(uri: vscode.Uri): Promise<string> {
43-
let document = await vscode.workspace.openTextDocument(unpackConfluenceUri(uri));
44-
let body = await parseMarkup(unpackConfluenceUri(uri), document.getText());
45-
let cssLink = cssUri("confluence.css");
43+
const document = await vscode.workspace.openTextDocument(unpackConfluenceUri(uri));
44+
const body = await parseMarkup(unpackConfluenceUri(uri), document.getText());
4645

47-
48-
// Security
49-
// https://code.visualstudio.com/api/extension-guides/webview#security
50-
return `<!DOCTYPE html>
51-
<html>
52-
<head>
53-
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
54-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'self' 'unsafe-inline'; img-src vscode-resource: https:; script-src vscode-resource:; style-src vscode-resource:;"/>
55-
<link rel="stylesheet" href="${cssLink}">
56-
</head>
57-
<body>
58-
${body}
59-
</body>
60-
</html>`;
46+
return body
6147
}
6248

6349
get onDidChange(): vscode.Event<vscode.Uri> {

src/extension.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,37 @@ import { packConfluenceUri, unpackConfluenceUri, ConfluenceContentProvider } fro
77

88
const path = require('path');
99

10+
import {cssUri} from './markupParser';
11+
12+
1013
function getRenderedContent(contentProvider: ConfluenceContentProvider, uri: vscode.Uri, panel: vscode.WebviewPanel) {
1114
contentProvider.provideTextDocumentContent(packConfluenceUri(uri)).then((renderedContent) => {
12-
panel.webview.html = renderedContent;
15+
// Security
16+
// https://code.visualstudio.com/api/extension-guides/webview#security
17+
18+
const cssFile = cssUri('confluence.css')
19+
let cssLink = ""
20+
if (cssFile) {
21+
const cssUrl = panel.webview.asWebviewUri(cssFile)
22+
cssLink = `<link rel="stylesheet" href="${cssUrl}">`
23+
}
24+
25+
panel.webview.html = `<!DOCTYPE html>
26+
<html>
27+
<head>
28+
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
29+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
30+
<meta http-equiv="Content-Security-Policy"
31+
content="default-src 'none';
32+
img-src self vscode-resource: https:;
33+
script-src self vscode-resource:;
34+
style-src 'unsafe-inline' self vscode-resource:;"/>
35+
${cssLink}
36+
</head>
37+
<body>
38+
${renderedContent}
39+
</body>
40+
</html>`;
1341
}, (reason) => {
1442
vscode.window.showErrorMessage(reason);
1543
});

src/markupParser.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ function imageUri(searchUri: vscode.Uri, imageLink: string) {
2020
}
2121

2222
function getUri(filepath: string, filename: string) {
23-
let extension = vscode.extensions.getExtension(EXTENTION_ID);
23+
const extension = vscode.extensions.getExtension(EXTENTION_ID);
2424
if (extension) {
25-
let extPath = extension.extensionPath;
25+
const extPath = extension.extensionPath;
2626

2727
// set special chema for resource:
2828
// https://code.visualstudio.com/api/extension-guides/webview#loading-local-content
29-
let uri = vscode.Uri.file(path.join(extPath, filepath, filename)).with({ scheme: 'vscode-resource' });
30-
return uri;
29+
const uri = vscode.Uri.file(path.join(extPath, filepath, filename))
30+
return uri
3131
}
3232
}
3333

3434
function emoticonUri(emoticonFile: string) {
35-
return getUri(EMOTICON_PATH, emoticonFile);
35+
const emoticonUrl = getUri(EMOTICON_PATH, emoticonFile)
36+
if (emoticonUrl) {
37+
return emoticonUrl.with({scheme: 'vscode-resource'});
38+
}
3639
}
3740

3841
export function cssUri(cssFile: string) {
@@ -69,7 +72,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
6972
tag = tag.replace(/\+([^\+]*)\+/g, "<u>$1</u>");
7073
tag = tag.replace(/\^([^\^]*)\^/g, "<sup>$1</sup>");
7174
tag = tag.replace(/~([^~]*)~/g, "<sub>$1</sub>");
72-
tag = tag.replace(/\{{2}(.*)\}{2}/g, `<code style='font-family: ${MONOSPACE_FONT_FAMILY}'>$1</code>`);
75+
tag = tag.replace(/\{{2}([^\{{2}]*)\}{2}/g, `<code style='font-family: ${MONOSPACE_FONT_FAMILY}'>$1</code>`);
7376
tag = tag.replace(/\?{2}(.*)\?{2}/g, "<cite>$1</cite>");
7477
tag = tag.replace(/\{color:(\w+)\}(.*)\{color\}/g, "<span style='color:$1;'>$2</span>");
7578

@@ -195,8 +198,8 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
195198
tag = tag.replace(/\*([^\*]*)\*/g, "<strong>$1</strong>");
196199
// line-through
197200
if ((!html_tag) && (!tag.match('<img')) && (!listFlag)) {
198-
tag = tag.replace(/-([\w ]*)-/g, "<span style='text-decoration: line-through;'>$1</span>");
199-
tag = tag.replace(/_([\w ]*)_/g, "<i>$1</i>");
201+
tag = tag.replace(/\B-([^-]*)-\B/g, " <span style='text-decoration: line-through;'>$1</span> ");
202+
tag = tag.replace(/_([^_]*)_/g, "<i>$1</i>");
200203
}
201204
} else {
202205
if (tag !== `<pre><code style='font-family: ${MONOSPACE_FONT_FAMILY}'>`) {

src/test/markupParser.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as path from 'path';
66
import { parseMarkup, cssUri } from '../markupParser';
77
import * as fs from 'fs';
88

9+
const HTML_FORMATTER = require('html-formatter');
10+
911
const TEST_FILES_ROOT = path.join(__dirname, "../../src/test/testfiles");
1012
const FIXTURES_ROOT = path.join(__dirname, "../../src/test/resources/fixtures");
1113

@@ -26,7 +28,7 @@ suite("markupParser Tests", function () {
2628

2729
// Defines a Mocha unit test
2830
test("Test CSS Uri", function () {
29-
const expected = vscode.Uri.file(path.join(__dirname, "../../media/css/dummy.css")).with({ "scheme": 'vscode-resource' });
31+
const expected = vscode.Uri.file(path.join(__dirname, "../../media/css/dummy.css"));
3032
const css = cssUri("dummy.css");
3133
assert.notEqual(css, undefined);
3234
if (css) {
@@ -54,7 +56,8 @@ suite("markupParser Tests", function () {
5456
const testFileUri = vscode.Uri.file(fullFilePath);
5557
const confluenceContent = fs.readFileSync(testFileUri.fsPath, 'utf8');
5658

57-
assert.equal(parseMarkup(testFileUri, confluenceContent), fixtureContent);
59+
const parsedMarkup = HTML_FORMATTER.render(parseMarkup(testFileUri, confluenceContent))
60+
assert.equal(parsedMarkup, fixtureContent);
5861
});
5962
});
6063
});
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
<p><h1>TITLE</h1></p><p><h2>Section One</h2></p><p>Section one.</p><p><h2>Section Two</h2></p><p>Section two.</p><p><ol class="initial"><li>Numbered List 1</li></p><p><li>Numbered List 2</li></p><p></ol></p><p><h2>Section Three</h2></p><p>Section three.</p><p><h2>Section Four</h2></p><p>Section four.</p>
1+
<p>
2+
<h1>TITLE</h1>
3+
</p>
4+
<p>
5+
<h2>Section One</h2>
6+
</p>
7+
<p>Section one.</p>
8+
<p>
9+
<h2>Section Two</h2>
10+
</p>
11+
<p>Section two.</p>
12+
<p>
13+
<ol class="initial">
14+
<li>Numbered List 1</li>
15+
</p>
16+
<p>
17+
<li>Numbered List 2</li>
18+
</p>
19+
<p></ol>
20+
</p>
21+
<p>
22+
<h2>Section Three</h2>
23+
</p>
24+
<p>Section three.</p>
25+
<p>
26+
<h2>Section Four</h2>
27+
</p>
28+
<p>Section four.</p>

0 commit comments

Comments
 (0)