import sanitizeHtml from 'sanitize-html'; export function cleanPublication(html){return sanitizeHtml(html,{ allowedTags:['p','h2','h3','h4','pre','code','strong','em','b','i','ul','ol','li','blockquote','figure','figcaption','img','table','thead','tbody','tr','th','td','br','a'], allowedAttributes:{a:['href','title','rel'],img:['src','alt','width','height','loading','decoding'],h2:['id'],h3:['id'],h4:['id'],pre:['tabindex','aria-label']}, allowedSchemes:['https','http'],allowProtocolRelative:false, transformTags:{a:(tag,attrs)=>({tagName:tag,attribs:{href:attrs.href||'',rel:'noopener noreferrer'}}),pre:(tag,attrs)=>({tagName:tag,attribs:{tabindex:'0','aria-label':'Пример кода, прокрутка клавишами со стрелками'}})}, exclusiveFilter:frame=>frame.tag==='img'&&(!frame.attribs.src?.startsWith('/visuals/')||frame.attribs.src.startsWith('//')), disallowedTagsMode:'discard',nonTextTags:['script','style','textarea','option','iframe','object','embed','form'], });}