Converting plain text to table markup

Plain text:
  • New lines are converted to table rows (<tr>)
  • Tabs or pipes (|) are converted to table cells (<td>)
  • Brackets ([ & ]) are converted to table headings (<th>)
  • 'Forgotten' cells are automatically added

Used on www.bvalmere.nl (for example) and in my CMS. Could be improved to also work with <thead>, colspan, et cetera.