import insane from 'insane';

const INSANE_OPTIONS = {
  allowedAttributes: {
    a: ['href', 'name', 'target'],
    img: ['src'],
  },
  allowedClasses: {
    span: ['grey'],
  },
  allowedSchemes: ['http', 'https', 'mailto', 'ssh', 'ftp', 'tg'],
  allowedTags: [
    'a',
    'article',
    'b',
    'blockquote',
    'br',
    'caption',
    'code',
    'del',
    'details',
    'div',
    'em',
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
    'hr',
    'i',
    'img',
    'ins',
    'kbd',
    'li',
    'main',
    'ol',
    'p',
    'pre',
    'section',
    'span',
    'strike',
    'strong',
    'sub',
    'summary',
    'sup',
    'table',
    'tbody',
    'td',
    'th',
    'thead',
    'tr',
    'u',
    'ul',
  ],
  filter: null,
  transformText: null,
};

export const stripHTMLTags = (text: string) => insane(text, INSANE_OPTIONS);
