Skip to content

Commit d43be3c

Browse files
committed
first try to fix issue #41
1 parent 6f77a2e commit d43be3c

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/markupParser.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,21 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
225225
tag = tag.replace(/</gi, '&lt;') + '<br />';
226226
}
227227

228-
const panel_re = /\{panel(.*)}/;
228+
const panel_re = /\{(panel|tip|info|note|warning)(.*)}/;
229229
if (! codeTagFlag && tag.match(panel_re)) {
230230
if (! panelTagFlag ) {
231231
let panelStyle = "";
232232
let titleStyle = "";
233-
tag = tag.replace(panel_re, function (m0, m1) {
234-
let res = '<div class="panel panel-body" $panelStyle>'
235-
const splits = m1.split(/[|:]/);
233+
let iconlessFlag = "";
234+
tag = tag.replace(panel_re, function (m0, m1, m2) {
235+
let panelClass = m1;
236+
237+
let res = `<div class="${panelClass} ${panelClass}-body" $panelStyle>`
238+
const splits = m2.split(/[|:]/);
236239
splits.forEach( (el:string) => {
237240
const elems = el.split('=');
238241
if (elems[0] === "title"){
239-
res = `<div class="panel panel-title" $titleStyle>${elems[1]}</div>${res}`;
242+
res = `<div class="${panelClass} ${panelClass}-title$iconlessFlag" $titleStyle>${elems[1]}</div>${res}`;
240243
}
241244
if (elems[0] === "titleBGColor"){
242245
if (titleStyle.length === 0) {
@@ -288,15 +291,27 @@ export function parseMarkup(sourceUri: vscode.Uri, sourceText: string) {
288291
titleStyle += ` border-width: ${elems[1]}; `;
289292
}
290293
}
294+
if (elems[0] === "icon" && elems[1] === "false"){
295+
iconlessFlag = "-iconless";
296+
}
291297
});
292298
if (titleStyle.length > 0) {
293299
titleStyle += `'`;
294300
}
295301
if (panelStyle.length > 0) {
296302
panelStyle += `'`;
297303
}
298-
res = res.replace('$panelStyle', panelStyle);
304+
if (panelClass != 'panel') {
305+
panelStyle = "";
306+
titleStyle = "";
307+
if (!res.match(`${panelClass}-title`)){
308+
res = `<div class="${panelClass} ${panelClass}-title$iconlessFlag"></div>${res}`;
309+
}
310+
}
311+
312+
res = res.replace('$iconlessFlag', iconlessFlag);
299313
res = res.replace('$titleStyle', titleStyle);
314+
res = res.replace('$panelStyle', panelStyle);
300315
return res;
301316
});
302317
panelTagFlag = true;

0 commit comments

Comments
 (0)