markup.ts 524 B

123456789101112
  1. // Copyright (C) 2012-2024 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. return 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. }