from markdown.extensions import Extension
from markdown.inlinepatterns import SubstituteTagPattern


class HardBreakExtension(Extension):
    def extendMarkdown(self, md):
        BREAK_RE = r' *\\\\\n'
        breakPattern = SubstituteTagPattern(BREAK_RE, 'br')
        md.inlinePatterns.register(breakPattern, 'hardbreak', 185)
