New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically generating id="" attributes #196
Conversation
return "\n" . $this->hashBlock($block) . "\n\n"; | ||
} | ||
protected function _doHeaders_callback_atx($matches) { | ||
protected function _doHeaders_callback_atx($matches) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thnx =) fixed
Looks nicely done. I don't mind the feature being in There's one thing I dislike: you are calling the generator function even when the I'm actually not sure about |
Looking at it a few more seconds, I realize that calling |
I will make the change so it becomes a function. The main problem I have with not using htmlspecialchars, is that it would allow a user to put a |
Based on what you said, it makes sense to me to to remove it for the class attribute though. |
Ok, granted. The user function is probably not to be entirely trusted for this. I suggest you use |
Ok, sounds good! |
Ready for review again. |
If you like, I can also commit my copy of |
One more suggestion: I can alter this slightly more to also turn all headers with id's into links that point to themselves. This is also how for example github behaves, so a user can click a header and get a reference in their addressbar. If you are interested in that change, I would be happy to add another setting that automatically inserts |
I'm not really sure what to respond to your last comment. I do think this is a valid thing to want, but I'm not too sure I want to add it. I don't want to bake every possible output into PHP Markdown with a configuration variable for each one. What I'd really like eventually is to move all the HTML output to a separate class, one where you can easily override and transform the output to what's needed. If you want to work on that, feel free. But I'm not interested in adding an option for transforming headers into links. I'm going to do a final check on this pull request sometime this weekend, and it'll probably get merged. And for the Readme.php, I'm going to keep it relying on the default configuration. |
Fair enough! I'm looking forward to the templating class. After merging, do you also think that a new release is on the horizon? This will allow me to integrate it into sculpin. |
Doesn't pass unit tests for the plain
You can see that for instance by parsing "Headers.text" in the "PHP Markdown" test suite in MDTest. https://github.com/michelf/mdtest/blob/master/PHP%20Markdown.mdtest/Headers.text Looks good for |
Oh man... I messed up with a later change. I see exactly what I did. |
That problem is now fixed. |
Hi @michelf !
This patch does the following:
Usage:
So.. you asked only for support in
MarkdownExtra
. Before I knew it I had written a full implementation inMarkdown
. Since this doesn't break anything inMarkdown
, I thought I would keep it in for now.But if you really only want this feature in
MarkdownExtra
, I am also happy to remove it fromMarkdown
for you.Let me know!
cc: @simensen