Improve compatibility with some Markdown renderers

Some Markdown flavors (e.g. GitLab Favored Markdown) convert headers
to URLs replacing all characters which are not Latin and numeric
with "-". This change improves the compatibility with them.

Note: this conflicts partially with 1fa9be4117a5481cecf526dd4a83a55fb4e08fd6 though