markup.ts 806 B

1234567891011121314151617181920
  1. // Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. // to be compatible with app/assets/javascripts/app/lib/app_post/i18n.coffee:267
  3. export const markup = (source: string): string =>
  4. source
  5. .replace(/\|\|(.+?)\|\|/gm, '<i>$1</i>')
  6. .replace(/\|(.+?)\|/gm, '<b>$1</b>')
  7. .replace(/_(.+?)_/gm, '<u>$1</u>')
  8. .replace(/\/\/(.+?)\/\//gm, '<del>$1</del>')
  9. .replace(/§(.+?)§/gm, '<kbd>$1</kbd>')
  10. .replace(/\[(.+?)\]\((.+?)\)/gm, '<a href="$2" target="_blank">$1</a>')
  11. export const cleanupMarkup = (source: string): string =>
  12. source
  13. .replace(/\|\|(.+?)\|\|/gm, '<i>$1</i>')
  14. .replace(/\|(.+?)\|/gm, '$1')
  15. .replace(/_(.+?)_/gm, '$1')
  16. .replace(/\/\/(.+?)\/\//gm, '$1')
  17. .replace(/§(.+?)§/gm, '$1')
  18. .replace(/\[(.+?)\]\((.+?)\)/gm, '$1')