@@ -290,9 +290,15 @@ MyDesklet.prototype = {
290290 //Main.notifyError("Complete Refresh Done", " "); // debug
291291 }
292292
293+ // parse markdown
294+ this . notecontent = this . parseMarkdown ( this . notecontent ) ;
295+
293296 // set the raw text
294297 this . notetext . set_text ( this . notecontent ) ;
295298
299+ // enable markup to support markdown
300+ this . notetext . clutter_text . set_use_markup ( true ) ;
301+
296302 // grab the Clutter.Text layout
297303 let ct = this . notetext . get_clutter_text ( ) ;
298304
@@ -307,6 +313,27 @@ MyDesklet.prototype = {
307313 //Main.notifyError("Text Refresh Done", " "); // debug
308314 } ,
309315
316+ parseMarkdown : function ( text ) {
317+ // bold by **text**
318+ text = text . replace ( / \* \* ( .* ?) \* \* / g, '<b>$1</b>' ) ;
319+ // italic by *text*
320+ text = text . replace ( / \* ( .* ?) \* / g, '<i>$1</i>' ) ;
321+ // strikethrough by ~~text~~
322+ text = text . replace ( / ~ ~ ( .* ?) ~ ~ / g, '<s>$1</s>' ) ;
323+ // monospace by `text`
324+ text = text . replace ( / ` ( .* ?) ` / g, '<tt>$1</tt>' ) ;
325+
326+ // headlines
327+ text = text . replace ( / ^ # ( .* ) $ / gm, '<span size="150%"><b>$1</b></span>' ) ;
328+ text = text . replace ( / ^ # # ( .* ) $ / gm, '<span size="130%"><b>$1</b></span>' ) ;
329+ text = text . replace ( / ^ # # # ( .* ) $ / gm, '<span size="110%"><b>$1</b></span>' ) ;
330+ text = text . replace ( / ^ # # # # ( .* ) $ / gm, '<span size="90%"><b>$1</b></span>' ) ;
331+ text = text . replace ( / ^ # # # # # ( .* ) $ / gm, '<span size="70%"><b>$1</b></span>' ) ;
332+ text = text . replace ( / ^ # # # # # # ( .* ) $ / gm, '<span size="50%"><b>$1</b></span>' ) ;
333+
334+ return text ;
335+ } ,
336+
310337 refreshDecoration : function ( ) {
311338 // desklet label (header)
312339 if ( this . useCustomLabel == true )
0 commit comments