process.js 388 B

123456789101112
  1. // process.js
  2. function processLine(line) {
  3. return line.trim()
  4. .replace(/[<>&"'\u0000-\u001F\u007E-\uFFFF]/g, function(x) {
  5. // escape HTML characters
  6. return '&#' + x.charCodeAt(0) + ';'
  7. })
  8. .replace(/\*(.*?)\*/g, function(x, m) {
  9. // automatically bold text between stars
  10. return '<b>' + m + '</b>';
  11. });
  12. }