-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Make the markdown parser able to generate anchors for headings #1032
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
Conversation
@@ -105,6 +105,10 @@ function getParseFunction(parserName, conf) { | |||
markedRenderer = new marked.Renderer(); | |||
|
|||
markedRenderer.heading = function(text, level) { |
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.
By default, marked's heading
renderer adds an id
attribute to headings, so you could simplify things by doing this instead (note that I've changed the option's name as well):
if (!conf.idInHeadings) {
markedRenderer.heading = function(text, level) {
// code
};
}
See my comment above. The plugin has tests here, but right now it's not possible to change the plugin's default settings in the test. That means you're off the hook for tests. |
Thanks @hegemonic for having a look at this PR. Will make the changes ASAP! |
@bobylito Still working on this? |
Thanks for the reminder, will make the changes right away :) On Thu, Jul 30, 2015 at 12:36 AM Jeff Williams [email protected]
|
Updated! :) |
@bobylito Sorry, but I'm not seeing the changes I requested. |
It uses the following configuration key in the markdown section : idInHeadings. If set to true it will make the headings generated in the markdown have id's like on github.
@hegemonic Sorry, wrong manipulations while amending my commit :/ |
Make the markdown parser able to generate anchors for headings
Merged to master. Thanks for making the changes! |
Thanks for accepting this modification. Hope I can contribute more :) On Wed, Aug 5, 2015 at 1:25 AM Jeff Williams [email protected]
|
This pull request gives the user a configuration so that he can choose to let the markdown parser add an anchor in the headings. This feature is very useful if you want to point directly to specific parts of a tutorial generated with markdown (that's my current use case).
To use the feature : set the attribute anchorInHeadings in the markdown part of the configuration file. The default is set to false.
I would have added some tests, but there seems to be none existing so far for the markdown. If it is necessary, could you give a hand in making them?
Cheers.