Find:
Code:
<([Hh][1-6])([^>]*)>(.*?)</\1>
Code:
import regex
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
text_str = regex.sub(r'''[-–—]''', ' ', match.group(3))
text_str = regex.sub(r''' {2,}''', ' ', text_str)
return '<{0}{1}>{2}</{0}>'.format(match.group(1), match.group(2), text_str)
I don't know about
graceful (I've always been strangely comforted by the aesthetics of the python one-liner, myself), but the above won't have the ten-space-or-less limitation.
** added the possibility to work with header tags that may have attributes.