Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • The 5 cm example had a line break between the 5 and the cm when I read the page in my phone. A joke?
  • Unfortunately this makes it much harder to read on narrow-width screens (e.g. mobile), where the use must scroll horizontally
  • Why even bother with the CSS class? Just apply text-wrap: nowrap; to all <code> elements and dispense with the fragile regex parsing.
  • You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML.
  • I do not count substitution as "parsing"
  • What do you mean you can't. I do it all the time
  • Tony the pony, he comes.
  • You can absolutely parse HTML with regex, so long as the document is finite in length. Every finite language is regular, hence can be parsed with regex's.
    by tyho
  • Parsing HTML with a regex is never a good option, but it's sometimes the only option.
  • You can parse a subset of it though, like if you're in control of the html yourself and avoid certain structures
  • Some commenters are missing that this is a reference to https://stackoverflow.com/a/1732454.