Skip to content

Commit e004197

Browse files
authored
Merge pull request #15 from denco/0.1.6
0.1.6
2 parents a88a0f9 + 754353a commit e004197

File tree

7 files changed

+76
-29
lines changed

7 files changed

+76
-29
lines changed

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.6
4+
* fix using css and render of emoticons rendering `Content-Security-Policy`
5+
* skip render empty lines
6+
* extend documentation
7+
* merge [Improvement to CSS + Ability to Change Monospace Font for Preview](https://github.com/denco/vscode-confluence-markup/pull/14), thanks to [macintacos](https://github.com/macintacos) for contributing:
8+
* Add configuration property: `confluenceMarkup.monospaceFont` for monospace font, default: `Menlo, Monaco, Consolas, monospace`
9+
* wrap all tags with paragraf
10+
311
## 0.1.5
412
* use webview api for rendering in vscode 1.33.x
513
* refactor confluence snippets

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
[![Installs](https://vsmarketplacebadge.apphb.com/installs-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
66
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/denco.confluence-markup.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=denco.confluence-markup)
77

8-
Adds syntax highlighting, snippets and preview for Confluence® Wiki files in Visual Studio Code.
8+
## Description
9+
Provide preview for Confluence Markup while editing them in VSCode
910

10-
Preview for Confluence Markup while editing them in VSCode
11+
Adds syntax highlighting, snippets and preview for Confluence® Wiki files in Visual Studio Code.
1112

13+
## Supported file extentions
1214
LanguageID: `confluence`
1315

1416
Defaulft supported file extentions:
@@ -26,8 +28,11 @@ The extension can be activated in two ways
2628
* Linux & Windows: `ctrl+k v`
2729
* MAC: `cmd+k v` or `ctrl+k v`
2830

29-
Confluence Documentation
31+
## Configuration properties
32+
* *confluenceMarkup.monospaceFont* = `Menlo, Monaco, Consolas, monospace`
33+
3034

35+
## Confluence documentation
3136
* [Wiki MarkUp](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html)
3237
* [Storage Format](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html)
3338

media/css/confluence.css

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
body {
2-
font-family: "Segoe WPC", "Segoe UI", "SFUIText-Light", "HelveticaNeue-Light", sans-serif, "Droid Sans Fallback";
2+
font-family: -apple-system,
3+
BlinkMacSystemFont,
4+
"Segoe UI",
5+
Roboto,
6+
Helvetica,
7+
Arial,
8+
sans-serif,
9+
"Apple Color Emoji",
10+
"Segoe UI Emoji",
11+
"Segoe UI Symbol";
312
font-size: 14px;
413
padding: 0 26px;
514
line-height: 1em;
@@ -37,7 +46,9 @@ h1 {
3746
border-bottom-style: solid;
3847
}
3948

40-
h1, h2, h3 {
49+
h1,
50+
h2,
51+
h3 {
4152
font-weight: normal;
4253
}
4354

@@ -47,25 +58,31 @@ blockquote {
4758
border-left: 5px solid;
4859
}
4960

50-
table, th, td {
51-
border: 1px solid;
52-
border-collapse: collapse;
61+
table,
62+
th,
63+
td {
64+
border: 1px solid;
65+
border-collapse: collapse;
66+
padding: 7px;
5367
}
5468

55-
pre > code {
69+
pre>code {
5670
display: inline-block;
5771
width: 90%;
5872
color: white;
5973
margin: 0px 5px;
6074
font-size: 14px;
61-
font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback";
62-
background-color:black;
75+
background-color: black;
6376
cursor: pointer;
6477
padding: 5px 1em;
65-
box-shadow: 1px 1px 1px rgba(0,0,0,.25);
78+
box-shadow: 1px 1px 1px rgba(0, 0, 0, .25);
6679
line-height: 1.5em;
6780
}
6881

82+
pre > code > p {
83+
margin: 0px
84+
}
85+
6986
ul {
7087
list-style-type: disc;
7188
}
@@ -77,9 +94,11 @@ ul.alternate {
7794
ol.initial {
7895
list-style: decimal;
7996
}
80-
ol.initial > ol {
97+
98+
ol.initial>ol {
8199
list-style-type: lower-alpha;
82100
}
83-
ol.initial > ol > ol {
101+
102+
ol.initial>ol>ol {
84103
list-style-type: lower-roman;
85-
}
104+
}

package.json

Lines changed: 12 additions & 2 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.5",
4+
"version": "0.1.6",
55
"publisher": "denco",
66
"description": "Confluence markup language support for Visual Studio Code",
77
"keywords": [
@@ -39,6 +39,16 @@
3939
],
4040
"main": "./out/extension",
4141
"contributes": {
42+
"configuration": {
43+
"title": "Confluence Markup",
44+
"properties": {
45+
"confluenceMarkup.monospaceFont": {
46+
"type": "string",
47+
"default": "Menlo, Monaco, Consolas, monospace",
48+
"description": "This is the value passed to the font-family CSS attribute for code in the preview. Provide it with a monospace font of your choice!"
49+
}
50+
}
51+
},
4252
"languages": [
4353
{
4454
"id": "confluence",
@@ -126,7 +136,7 @@
126136
"eslint": "^5.16.0",
127137
"tslint": "^5.16.0",
128138
"typescript": "^3.3.0",
129-
"vsce": "^1.60.0",
139+
"vsce": "^1.66.0",
130140
"vscode": "^1.1.23"
131141
},
132142
"__metadata": {

src/ConfluenceContentProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ export class ConfluenceContentProvider implements vscode.TextDocumentContentProv
4444
let body = await parseMarkup(unpackConfluenceUri(uri), document.getText());
4545
let cssLink = cssUri("confluence.css");
4646

47+
48+
// Security
49+
// https://code.visualstudio.com/api/extension-guides/webview#security
4750
return `<!DOCTYPE html>
4851
<html>
4952
<head>
5053
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
54+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src vscode-resource:; style-src vscode-resource:;"/>
5155
<link rel="stylesheet" href="${cssLink}">
5256
</head>
5357
<body>

src/markupParser.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
const EXTENTION_ID = 'denco.confluence-markup';
88
const EMOTICON_PATH = '/media/emoticons/';
99
const CSS_PATH = '/media/css/';
10+
const MONOSPACE_FONT_FAMILY = vscode.workspace.getConfiguration("confluenceMarkup").monospaceFont;
1011

1112
function imageUri(searchUri: vscode.Uri, imageLink: string) {
1213
let imageUri
@@ -39,7 +40,7 @@ export function cssUri(cssFile: string) {
3940
}
4041

4142
export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
42-
//TODO: use Tokenazer instead of line loop
43+
//TODO: use Tokenizer instead of line loop
4344

4445
var result = '';
4546
let listTag = '';
@@ -53,14 +54,18 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
5354
let tag = entry;
5455
let html_tag = false;
5556

57+
if (tag.length === 0 ) {
58+
continue;
59+
}
60+
5661
if (codeTagFlag == 0) {
5762
tag = tag.replace(/h(\d+)\.\s([^\n]+)/g, "<h$1>$2</h$1>");
5863

5964
// tag = tag.replace(/_([^_]*)_/g, "<em>$1</em>");
6065
tag = tag.replace(/\+([^\+]*)\+/g, "<u>$1</u>");
6166
tag = tag.replace(/\^([^\^]*)\^/g, "<sup>$1</sup>");
6267
tag = tag.replace(/~([^~]*)~/g, "<sub>$1</sub>");
63-
tag = tag.replace(/\{{2}(.*)\}{2}/g, "<code>$1</code>");
68+
tag = tag.replace(/\{{2}(.*)\}{2}/g, `<code style='font-family: ${MONOSPACE_FONT_FAMILY}'>$1</code>`);
6469
tag = tag.replace(/\?{2}(.*)\?{2}/g, "<cite>$1</cite>");
6570
tag = tag.replace(/\{color:(\w+)\}(.*)\{color\}/g, "<span style='color:$1;'>$2</span>");
6671

@@ -122,14 +127,14 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
122127
// code
123128
// online code tag
124129
tag = tag.replace(/\{(noformat|code)[^\}]*\}(.*)\{(noformat|code)\}/, function (m0, m1, m2) {
125-
return "<pre><code>" + m2.replace(/</gi, '&lt;') + "</code></pre>";
130+
return `<pre><code style='font-family: ${MONOSPACE_FONT_FAMILY}'>${m2.replace(/</gi, '&lt;')}</code></pre>`;
126131
});
127132

128133
let re = /\{[(code)|(noformat)].*\}/;
129134
let match = tag.match(re);
130135
if (match) {
131136
if (codeTagFlag === 0) {
132-
tag = '<pre><code>';
137+
tag = `<pre><code style='font-family: ${MONOSPACE_FONT_FAMILY}'>`;
133138
codeTagFlag = 1;
134139
} else {
135140
tag = '</pre></code>';
@@ -190,23 +195,19 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
190195
tag = tag.replace(/_([\w ]*)_/g, "<i>$1</i>");
191196
}
192197
} else {
193-
if (tag !== '<pre><code>') {
198+
if (tag !== `<pre><code style='font-family: ${MONOSPACE_FONT_FAMILY}'>`) {
194199
tag = tag.replace(/</gi, '&lt;') + '<br />';
195200
}
196201
}
197202

198-
if (tag.match(/^s*$/)) {
199-
tag = '<br />';
200-
}
201-
202203
//close table
203204
if (!tag.match(/<\/tr>$/) && tableFlag) {
204205
tag = '</table>' + tag;
205206
tableFlag = false;
206207
}
207208

208-
result += tag;
209+
result += "<p>" + tag + "</p>";
209210
}
210211

211212
return result;
212-
}
213+
}

src/test/markupParser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ suite("markupParser Tests", function () {
2222

2323
test("Test render headers", function () {
2424
const testFile = vscode.Uri.file(path.join(__dirname, "../../src/test/testfiles/nix/scoped/headings.confluence"));
25-
const expected = '<h1>Heading 1</h1><br /><h2>Heading 2</h2><br /><h3>Heading 3</h3><br /><h4>Heading 4</h4><br /><h5>Heading 5</h5><br /><h6>Heading 6</h6><br />'
25+
const expected = '<p><h1>Heading 1</h1></p><p><h2>Heading 2</h2></p><p><h3>Heading 3</h3></p><p><h4>Heading 4</h4></p><p><h5>Heading 5</h5></p><p><h6>Heading 6</h6></p>'
2626
const content = fs.readFileSync(testFile.fsPath, 'utf8');
2727
assert.equal(parseMarkup(testFile, content), expected);
2828
});

0 commit comments

Comments
 (0)