const esc=v=>String(v).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); function inline(text){let result='',from=0;for(const m of text.matchAll(/\[([^\]\n]{1,200})\]\((https:\/\/[^\s)]+)\)/g)){result+=esc(text.slice(from,m.index));let url;try{url=new URL(m[2]);}catch{}result+=url?.protocol==='https:'?''+esc(m[1])+'':esc(m[0]);from=m.index+m[0].length;}return result+esc(text.slice(from));} export function renderNewsBody(value){let html='',paragraph=[],list=false;const flush=()=>{if(paragraph.length){html+='

'+inline(paragraph.join(' '))+'

';paragraph=[];}if(list){html+='';list=false;}};for(const raw of String(value).replace(/\r/g,'').split('\n')){const line=raw.trim();if(!line){flush();continue;} const picture=line.match(/^!\[([^\]\n]{1,200})\]\((https:\/\/www\.dunerealms\.com\/assets\/(?:seals\/)?[a-z0-9-]+\.(?:png|webp|jpg))\)$/i); if(picture){flush();const seal=picture[2].includes('/seals/');html+='
'+esc(picture[1])+'
'+esc(picture[1])+'
';continue;} const video=line.match(/^\[([^\]\n]{1,200})\]\((https:\/\/www\.dunerealms\.com\/assets\/video\/[a-z0-9-]+\.mp4)\)$/i); if(video){flush();html+='
Enable sound in the player for the original epic soundtrack.
';continue;} const heading=line.match(/^#{1,3}\s+(.+)$/),bullet=line.match(/^[-*]\s+(.+)$/);if(heading){flush();html+='

'+inline(heading[1])+'

';}else if(bullet){if(paragraph.length)flush();if(!list){html+='