@@ -45,7 +45,7 @@ export function cssUri(cssFile: string) {
4545export function parseMarkup ( sourceUri : vscode . Uri , sourceText : string ) {
4646 //TODO: use Tokenizer instead of line loop
4747
48- var result = '' ;
48+ let result = '' ;
4949 let listTag = '' ;
5050 let listStyle = '' ;
5151 let codeTagFlag = false ;
@@ -54,7 +54,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
5454 let listFlag = false ;
5555 let listArr : string [ ] = [ ] ;
5656
57- for ( let entry of sourceText . split ( / \r ? \n / gi) ) {
57+ for ( const entry of sourceText . split ( / \r ? \n / gi) ) {
5858 let tag = entry ;
5959 let html_tag = false ;
6060
@@ -70,10 +70,10 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
7070 tag = tag . replace ( / h ( \d + ) \. \s ( [ ^ \n ] + ) / g, "<h$1>$2</h$1>" ) ;
7171
7272 // tag = tag.replace(/_([^_]*)_/g, "<em>$1</em>");
73- tag = tag . replace ( / \+ ( [ ^ \ +] * ) \+ / g, "<u>$1</u>" ) ;
74- tag = tag . replace ( / \^ ( [ ^ \ ^] * ) \^ / g, "<sup>$1</sup>" ) ;
73+ tag = tag . replace ( / \+ ( [ ^ + ] * ) \+ / g, "<u>$1</u>" ) ;
74+ tag = tag . replace ( / \^ ( [ ^ ^ ] * ) \^ / g, "<sup>$1</sup>" ) ;
7575 tag = tag . replace ( / ~ ( [ ^ ~ ] * ) ~ / g, "<sub>$1</sub>" ) ;
76- tag = tag . replace ( / \{ { 2 } ( [ ^ \ {{ 2 } ] * ) \} { 2 } / g, `<code style='font-family: ${ MONOSPACE_FONT_FAMILY } '>$1</code>` ) ;
76+ tag = tag . replace ( / \{ { 2 } ( [ ^ { { 2 } ] * ) \} { 2 } / g, `<code style='font-family: ${ MONOSPACE_FONT_FAMILY } '>$1</code>` ) ;
7777 tag = tag . replace ( / \? { 2 } ( .* ) \? { 2 } / g, "<cite>$1</cite>" ) ;
7878 tag = tag . replace ( / \{ c o l o r : ( \w + ) \} ( .* ) \{ c o l o r \} / g, "<span style='color:$1;'>$2</span>" ) ;
7979
@@ -95,7 +95,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
9595
9696 tag = tag . replace ( / \\ \\ / gi, '<br/>' ) ;
9797
98- let re_href = / \[ ( [ ^ \ || \] ] * ) \| ? ( [ ^ \[ | \ |] * ) ? \] / g
98+ const re_href = / \[ ( [ ^ | | \] ] * ) \| ? ( [ ^ [ | | ] * ) ? \] / g
9999 if ( tag . match ( re_href ) ) {
100100 tag = tag . replace ( re_href , function ( m0 :string , m1 :string , m2 :string ) {
101101 if ( m1 !== undefined && ( m1 . startsWith ( ' ' ) || m1 . endsWith ( '\\' ) ) ) {
@@ -112,17 +112,17 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
112112 html_tag = true ;
113113 }
114114 //img
115- let img = / ! ( [ ^ | ] * ) \| ? .* ! / ;
116- let match = tag . match ( img ) ;
117- if ( match ) {
118- tag = '<img src="' + imageUri ( sourceUri , match [ 1 ] ) + '"/>' ;
115+ const img_re = / ! ( [ ^ | ] * ) \| ? .* ! / ;
116+ const img_match = tag . match ( img_re ) ;
117+ if ( img_match ) {
118+ tag = '<img src="' + imageUri ( sourceUri , img_match [ 1 ] ) + '"/>' ;
119119 }
120120
121121 //Table
122- let tab_th_re = / \s * [ ^ { ] * \| { 2 } [ ^ } ] * $ / gi;
123- let tab_td_re = / \s * [ ^ { ] * \| [ ^ } ] * $ / gi;
122+ const tab_th_re = / \s * [ ^ { ] * \| { 2 } [ ^ } ] * $ / gi;
123+ const tab_td_re = / \s * [ ^ { ] * \| [ ^ } ] * $ / gi;
124124 if ( ! html_tag && ( tag . match ( tab_th_re ) || tag . match ( tab_td_re ) ) ) {
125- tag = tag . replace ( / ^ \| { 2 , } / , '\|\ |' ) ;
125+ tag = tag . replace ( / ^ \| { 2 , } / , '| |' ) ;
126126 tag = tag . replace ( / ^ \| { 2 } / , '<th>' ) ;
127127 tag = tag . replace ( / \| { 2 } $ / , '</th>' ) ;
128128 tag = tag . replace ( / \| { 2 } / gi, '</th><th>' ) ;
@@ -139,13 +139,13 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
139139
140140 // code
141141 // online code tag
142- tag = tag . replace ( / \{ ( n o f o r m a t | c o d e ) [ ^ \ }] * \} ( .* ) \{ ( n o f o r m a t | c o d e ) \} / , function ( m0 , m1 , m2 ) {
142+ tag = tag . replace ( / \{ ( n o f o r m a t | c o d e ) [ ^ } ] * \} ( .* ) \{ ( n o f o r m a t | c o d e ) \} / , function ( m0 , m1 , m2 ) {
143143 return `<pre><code style='font-family: ${ MONOSPACE_FONT_FAMILY } '>${ m2 . replace ( / < / gi, '<' ) } </code></pre>` ;
144144 } ) ;
145145
146- let re = / \{ [ ( c o d e ) | ( n o f o r m a t ) ] .* \} / ;
147- let match = tag . match ( re ) ;
148- if ( match ) {
146+ const code_re = / \{ [ ( c o d e ) | ( n o f o r m a t ) ] .* \} / ;
147+ const code_match = tag . match ( code_re ) ;
148+ if ( code_match ) {
149149 if ( ! codeTagFlag ) {
150150 tag = `<pre><code style='font-family: ${ MONOSPACE_FONT_FAMILY } '>` ;
151151 codeTagFlag = true ;
@@ -155,16 +155,16 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
155155 }
156156 }
157157
158- let panel_re = / \{ p a n e l ( .* ) } / ;
158+ const panel_re = / \{ p a n e l ( .* ) } / ;
159159 if ( tag . match ( panel_re ) ) {
160160 if ( ! panelTagFlag ) {
161161 let panelStyle = "" ;
162162 let titleStyle = "" ;
163- tag = tag . replace ( panel_re , function ( m0 , m1 , m2 ) {
163+ tag = tag . replace ( panel_re , function ( m0 , m1 ) {
164164 let res = '<div class="panel panel-body" $panelStyle>'
165- let splits = m1 . split ( / [ \ |: ] / ) ;
166- splits . forEach ( ( el :String ) => {
167- let elems = el . split ( '=' ) ;
165+ const splits = m1 . split ( / [ | : ] / ) ;
166+ splits . forEach ( ( el :string ) => {
167+ const elems = el . split ( '=' ) ;
168168 if ( elems [ 0 ] === "title" ) {
169169 res = `<div class="panel panel-title" $titleStyle>${ elems [ 1 ] } </div>${ res } ` ;
170170 }
@@ -238,35 +238,35 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
238238
239239 if ( ! codeTagFlag ) {
240240 // lists
241- re = / ^ ( [ - | \ *| # ] + ) \s ( .* ) / ;
242- match = tag . match ( re ) ;
243- if ( match ) {
241+ const li_re = / ^ ( [ - | * | # ] + ) \s ( .* ) / ;
242+ const li_match = tag . match ( li_re ) ;
243+ if ( li_match ) {
244244 listFlag = true ;
245245 listStyle = '' ;
246246 tag = '' ;
247- if ( match [ 1 ] . match ( / # $ / ) ) {
247+ if ( li_match [ 1 ] . match ( / # $ / ) ) {
248248 listTag = 'ol' ;
249249 // reset ol after 3rd level
250250 // add count of non-ol elements for mixed lists
251- if ( ( match [ 1 ] . length + ( match [ 1 ] . match ( / [ - | \ *] / g) || [ ] ) . length ) % 3 === 1 ) {
251+ if ( ( li_match [ 1 ] . length + ( li_match [ 1 ] . match ( / [ - | * ] / g) || [ ] ) . length ) % 3 === 1 ) {
252252 listStyle = ' class="initial"' ;
253253 }
254254 }
255- if ( match [ 1 ] . match ( / [ - | \ *] $ / ) ) {
255+ if ( li_match [ 1 ] . match ( / [ - | * ] $ / ) ) {
256256 listTag = 'ul' ;
257257 }
258- if ( match [ 1 ] . match ( / - $ / ) ) {
258+ if ( li_match [ 1 ] . match ( / - $ / ) ) {
259259 listStyle = ' class="alternate"' ;
260260 }
261- if ( match [ 1 ] . length > listArr . length ) {
261+ if ( li_match [ 1 ] . length > listArr . length ) {
262262 tag = '<' + listTag + listStyle + '>' ;
263263 listArr . push ( listTag ) ;
264264 }
265- if ( match [ 1 ] . length < listArr . length ) {
266- tag = '</' + listArr . slice ( match [ 1 ] . length , listArr . length ) . reverse ( ) . join ( '></' ) + '>' ;
267- listArr = listArr . slice ( 0 , match [ 1 ] . length ) ;
265+ if ( li_match [ 1 ] . length < listArr . length ) {
266+ tag = '</' + listArr . slice ( li_match [ 1 ] . length , listArr . length ) . reverse ( ) . join ( '></' ) + '>' ;
267+ listArr = listArr . slice ( 0 , li_match [ 1 ] . length ) ;
268268 }
269- tag += "<li>" + match [ 2 ] + "</li>" ;
269+ tag += "<li>" + li_match [ 2 ] + "</li>" ;
270270 }
271271
272272
@@ -282,7 +282,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
282282 tag = tag . replace ( / - { 3 } / gi, '—' ) ;
283283 tag = tag . replace ( / - { 2 } / gi, '–' ) ;
284284 // strong
285- tag = tag . replace ( / \* ( [ ^ \ *] * ) \* / g, "<strong>$1</strong>" ) ;
285+ tag = tag . replace ( / \* ( [ ^ * ] * ) \* / g, "<strong>$1</strong>" ) ;
286286 // line-through
287287 if ( ( ! html_tag ) && ( ! tag . match ( '<img' ) ) && ( ! listFlag ) ) {
288288 tag = tag . replace ( / \B - ( [ ^ - ] * ) - \B / g, " <span style='text-decoration: line-through;'>$1</span> " ) ;
0 commit comments