Skip to content

Commit

Permalink
+ improve the live news formatting with md->html
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Dec 11, 2023
1 parent 6af71d4 commit 910d578
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions themes/default/css/admin.css
Expand Up @@ -317,13 +317,14 @@ fieldset dl {
}

#ourAnnouncements dt {
padding: 4px 6px 2px 6px;
padding: 4px 6px 0 6px;
border-top: 1px solid;

}

#ourAnnouncements dt a {
font-weight: bold;
display: block;
font-size: 1.1em;
}

#ourAnnouncements dd {
Expand Down
15 changes: 15 additions & 0 deletions themes/default/scripts/admin.js
Expand Up @@ -80,6 +80,21 @@ elk_AdminIndex.prototype.setAnnouncement = function (announcement)
sMessages = this.init_news ? oElem.innerHTML : '',
sMessage = '';

announcement.body = announcement.body.replace('\r\n\r\n', '\n');

// Some markup to html conversion
let re = new RegExp('^#{1,4}(.*)$', 'ugm');
announcement.body = announcement.body.replace(re, '<strong>$1</strong>');

re = new RegExp('\\*\\*(.*)\\*\\*', 'ug');
announcement.body = announcement.body.replace(re, '<strong>$1</strong>');

re = new RegExp('^\\* (.*)$', 'ugm');
announcement.body = announcement.body.replace(re, '&#x2022; $1');

re = new RegExp('^ {0,1}- (.*)$', 'ugm');
announcement.body = announcement.body.replace(re, '&#x2022; $1');

sMessage = this.opt.sAnnouncementMessageTemplate.replace('%href%', announcement.html_url).replace('%subject%', announcement.name).replace('%time%', announcement.published_at.replace(/[TZ]/g, ' ')).replace('%message%', announcement.body).replace(/\n/g, '<br />').replace(/\r/g, '');

oElem.innerHTML = sMessages + this.opt.sAnnouncementTemplate.replace('%content%', sMessage);
Expand Down

0 comments on commit 910d578

Please sign in to comment.