Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added preprocess() and fixed minor bug in atx header regular expression. #90

Merged
merged 2 commits into from Jun 15, 2012

Conversation

Projects
None yet
3 participants
Collaborator

joestump commented Jun 14, 2012

Hey @trentm, we use python-markdown2 at Sprint.ly and love it. We have our own flavoring to our Markdown (auto-linking tickets, URLs, etc.) and wanted to push back two minor changes I made for our own uses.

  1. I changed the atx regular expression to require one or more spaces between the # and the header text. It's not explicitly stated on DF as being required, but his examples all show a single space. This keeps comments, hash tags, and ticket numbers at the beginning of the line from turning into an h1.
  2. I added a preprocess() method that runs prior to the formatting for sub-classes. It's postprocess()'s cousin.
Owner

trentm commented Jun 15, 2012

$ cat asdf.txt 
hi
there
#buddy
boy

$ markdown2 asdf.txt 
<p>hi
there</p>

<h1>buddy</h1>

<p>boy</p>

Yah, that's crap. Looks good.

@trentm trentm added a commit that referenced this pull request Jun 15, 2012

@trentm trentm Merge pull request #90 from joestump/master
Added preprocess() and fixed minor bug in atx header regular expression.
bfc42ab

@trentm trentm merged commit bfc42ab into trentm:master Jun 15, 2012

Owner

trentm commented Jun 15, 2012

Rev'd to 2.0.0 (it is a backward incompat change) and pushed to pypi. Thanks.

laiwei commented on d2326c3 Jul 17, 2012

why require a space?

I see, in github`s markdown , does not require a space in headers.

Collaborator

joestump replied Jul 17, 2012

I cover this in my notes in the original pull request:
#90

Owner

trentm commented Jul 17, 2012

I wonder if we could guard against the accidental ticket/hash headerification by not making a header inside a paragraph. That would just that you couldn't start a paragraph with a

#tag this is my
Paragraph 
Collaborator

joestump commented Jul 17, 2012

My guess is a newline would be a better way to tackle it. e.g. "Headers must have a new line between them and the next text block to render correctly."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment