@@ -49,6 +49,7 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
4949 let listTag = '' ;
5050 let listStyle = '' ;
5151 let codeTagFlag = false ;
52+ let panelTagFlag = false ;
5253 let tableFlag = false ;
5354 let listFlag = false ;
5455 let listArr : string [ ] = [ ] ;
@@ -98,7 +99,6 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
9899 let esc_href = / \[ \s * ( [ ^ | ] * ) ? \| ? ( [ ^ | ] .* ) [ \s + | \\ ] \] / g
99100 if ( tag . match ( re_href ) ) {
100101 tag = tag . replace ( re_href , function ( m0 , m1 , m2 ) {
101- console . log ( `aaa: >${ m1 } <, >${ m2 } <` ) ;
102102 if ( ( m1 . length !== 0 ) && ( m2 . length !== 0 ) ) {
103103 return "<a href='" + m2 + "'>" + m1 + "</a>" ;
104104 } else {
@@ -117,8 +117,8 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
117117 }
118118
119119 //Table
120- let tab_th_re = / \s * \| { 2 } . * $ / gi;
121- let tab_td_re = / \s * \| . * $ / gi;
120+ let tab_th_re = / \s * [ ^ { ] * \| { 2 } [ ^ } ] * $ / gi;
121+ let tab_td_re = / \s * [ ^ { ] * \| [ ^ } ] * $ / gi;
122122 if ( ! html_tag && ( tag . match ( tab_th_re ) || tag . match ( tab_td_re ) ) ) {
123123 tag = tag . replace ( / ^ \| { 2 , } / , '\|\|' ) ;
124124 tag = tag . replace ( / ^ \| { 2 } / , '<th>' ) ;
@@ -153,6 +153,87 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
153153 }
154154 }
155155
156+ let panel_re = / \{ p a n e l ( .* ) } / ;
157+ if ( tag . match ( panel_re ) ) {
158+ if ( ! panelTagFlag ) {
159+ let panelStyle = "" ;
160+ let titleStyle = "" ;
161+ tag = tag . replace ( panel_re , function ( m0 , m1 , m2 ) {
162+ let res = '<div class="panel panel-body" $panelStyle>'
163+ let splits = m1 . split ( / [ \| : ] / ) ;
164+ splits . forEach ( ( el :String ) => {
165+ let elems = el . split ( '=' ) ;
166+ if ( elems [ 0 ] === "title" ) {
167+ res = `<div class="panel panel-title" $titleStyle>${ elems [ 1 ] } </div>${ res } ` ;
168+ }
169+ if ( elems [ 0 ] === "titleBGColor" ) {
170+ if ( titleStyle . length === 0 ) {
171+ titleStyle = `style='background-color: ${ elems [ 1 ] } ;` ;
172+ } else {
173+ titleStyle += ` background-color: ${ elems [ 1 ] } ;` ;
174+ }
175+ }
176+ if ( elems [ 0 ] === "bgColor" ) {
177+ if ( panelStyle . length === 0 ) {
178+ panelStyle = `style='background-color: ${ elems [ 1 ] } ;` ;
179+ } else {
180+ panelStyle += ` background-color: ${ elems [ 1 ] } ;` ;
181+ }
182+ }
183+ if ( elems [ 0 ] === "borderStyle" ) {
184+ if ( panelStyle . length === 0 ) {
185+ panelStyle = `style='border-style: ${ elems [ 1 ] } ; ` ;
186+ } else {
187+ panelStyle += ` border-style: ${ elems [ 1 ] } ; ` ;
188+ }
189+ if ( titleStyle . length === 0 ) {
190+ titleStyle = `style='border-style: ${ elems [ 1 ] } ; border-bottom:none; ` ;
191+ } else {
192+ titleStyle += ` border-style: ${ elems [ 1 ] } ; border-bottom:none; ` ;
193+ }
194+ }
195+ if ( elems [ 0 ] === "borderColor" ) {
196+ if ( panelStyle . length === 0 ) {
197+ panelStyle = `style='border-color: ${ elems [ 1 ] } ; ` ;
198+ } else {
199+ panelStyle += ` border-color: ${ elems [ 1 ] } ; ` ;
200+ }
201+ if ( titleStyle . length === 0 ) {
202+ titleStyle = `style='border-color: ${ elems [ 1 ] } ; ` ;
203+ } else {
204+ titleStyle += ` border-color: ${ elems [ 1 ] } ; ` ;
205+ }
206+ }
207+ if ( elems [ 0 ] === "borderWidth" ) {
208+ if ( panelStyle . length === 0 ) {
209+ panelStyle = `style='border-width: ${ elems [ 1 ] } ; ` ;
210+ } else {
211+ panelStyle += ` border-width: ${ elems [ 1 ] } ; ` ;
212+ }
213+ if ( titleStyle . length === 0 ) {
214+ titleStyle = `style='border-width: ${ elems [ 1 ] } ; ` ;
215+ } else {
216+ titleStyle += ` border-width: ${ elems [ 1 ] } ; ` ;
217+ }
218+ }
219+ } ) ;
220+ if ( titleStyle . length >= 0 ) {
221+ titleStyle += `'` ;
222+ }
223+ if ( panelStyle . length >= 0 ) {
224+ panelStyle += `'` ;
225+ }
226+ res = res . replace ( '$panelStyle' , panelStyle ) ;
227+ res = res . replace ( '$titleStyle' , titleStyle ) ;
228+ return res ;
229+ } ) ;
230+ panelTagFlag = true ;
231+ } else {
232+ tag = '</div>' ;
233+ panelTagFlag = false ;
234+ }
235+ }
236+
156237 if ( ! codeTagFlag ) {
157238 // lists
158239 re = / ^ ( [ - | \* | # ] + ) \s ( .* ) / ;
@@ -216,7 +297,6 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
216297 tag = '</table>' + tag ;
217298 tableFlag = false ;
218299 }
219- console . log ( tag ) ;
220300 result += "<p>" + tag + "</p>" ;
221301 }
222302
0 commit comments