My implementation of markdown turns double hyphens into endashes. E.g., a -- b becomes a – b
But sometimes users write a - b when they mean a -- b. I'd like a regular expression to fix this.
Obviously body.gsub(/ - /, " -- ")
comes to mind, but this messes up markdown's unordered lists – i.e., if a line starts - list item
, it will become -- list item
. So solution must only swap out hyphens when there is a word character somewhere to their left