@@ -8,6 +8,17 @@ import { open } from 'fs';
88const EXTENTION_ID = 'denco.confluence-markup' ;
99const EMOTICON_PATH = '/resources/emoticons/' ;
1010
11+ function imageUri ( searchUri : vscode . Uri , imageLink : string ) {
12+ let imageUri
13+ if ( imageLink . match ( / ^ ( h t ) | ( f ) t p s ? : \/ \/ / ) ) {
14+ imageUri = vscode . Uri . parse ( imageLink ) ;
15+ } else {
16+ let extPath = path . dirname ( searchUri . fsPath ) ;
17+ imageUri = vscode . Uri . file ( path . join ( extPath , imageLink ) ) ;
18+ }
19+ return imageUri ;
20+ }
21+
1122function emoticonUri ( emoticonFile : string ) {
1223 let extPath = vscode . extensions . getExtension ( EXTENTION_ID ) . extensionPath ;
1324 let emoticonUri = vscode . Uri . file ( path . join ( extPath , EMOTICON_PATH , emoticonFile ) ) ;
@@ -30,7 +41,7 @@ export async function parseMarkup(sourceText: string, sourceUri: vscode.Uri) {
3041 tag = tag . replace ( / - { 3 } / gi, '—' ) ;
3142 tag = tag . replace ( / - { 2 } / gi, '–' ) ;
3243
33- tag = tag . replace ( / _ ( [ ^ _ ] * ) _ / g, "<em>$1</em>" ) ;
44+ // tag = tag.replace(/_([^_]*)_/g, "<em>$1</em>");
3445 tag = tag . replace ( / \+ ( [ ^ \+ ] * ) \+ / g, "<u>$1</u>" ) ;
3546 tag = tag . replace ( / \^ ( [ ^ \^ ] * ) \^ / g, "<sup>$1</sup>" ) ;
3647 tag = tag . replace ( / ~ ( [ ^ ~ ] * ) ~ / g, "<sub>$1</sub>" ) ;
@@ -55,6 +66,14 @@ export async function parseMarkup(sourceText: string, sourceUri: vscode.Uri) {
5566 tag = tag . replace ( / \( ! \) / g, '<img alt="(warning)" src="' + emoticonUri ( 'warning.png' ) + '"/>' ) ;
5667
5768 tag = tag . replace ( / \[ ( [ ^ | ] * ) ? \| ? ( [ ^ | ] * ) \] / g, "<a href='$2'>$1</a>" ) ;
69+
70+ //img
71+ let img = / ! ( .* ) ! / ;
72+ let match = tag . match ( img ) ;
73+ if ( match ) {
74+ tag = '<img src="' + imageUri ( sourceUri , match [ 1 ] ) + '"/>' ;
75+ }
76+
5877 }
5978
6079 // code
0 commit comments