Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Add new getParser public API #285

Merged
merged 1 commit into from
Nov 4, 2016
Merged

Add new getParser public API #285

merged 1 commit into from
Nov 4, 2016

Conversation

revin
Copy link
Collaborator

@revin revin commented Nov 3, 2016

Here's a speculative change that adds a new public API:

getParser([options])

Returns a marky-markdown-flavored markdown-it parser object. You can attach other markdown-it plugins, inspect the internals for debugging, etc... For example:

var marky = require('marky-markdown')
var someMarkdownItPlugin = require('some-fake-markdown-it-plugin')

var parser = marky.getParser({ package: somePackage, highlightSyntax: false })

parser.use(someMarkdownItPlugin)

var html = parser.render(html)

marky.getParser(options).render(markdown) is the exact same thing as the existing marky.render(markdown, options)

@revin
Copy link
Collaborator Author

revin commented Nov 3, 2016

The main reason I'm proposing this is that I'm working on a live in-browser marky testing app, and having access to the parser made it possible to get access to the markdown-it token stream so I could do a Debug view. It also ends up addressing #247, which is nice.

If everybody likes this change, I can update the documentation and add some tests.

return githubLinkify(parser)
}

render.renderPackageDescription = function (description) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does PackageDescription mean here? feel like we may soon be removing this when we get rid of packagize.js with #282

otherwise this is a misleading name. shouldn't affect this PR, but we should change that if it means the full README

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the name this method has had since before I started working on marky; last I saw many months ago, the npm web site was using it for rendering package.json description fields into HTML for use in on package pages.

If they're not using it anymore, I'd be in favor of deprecating/removing it. People will be able to do basically the same thing by calling marky.getParser().renderInline(markdownSnippet), but honestly it wouldn't surprise me if nobody at all is using it anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, and this has absolutely nothing to do with the packagize stuff!

and finally, the only reason it shows up in the diff here is because I moved it up earlier in the file so it grouped the module exports together 😕

yay legacy

@ashleygwilliams ashleygwilliams added this to the 10.0.0 milestone Nov 4, 2016
@ashleygwilliams
Copy link
Contributor

haha ok cool so- i think this looks awesome and i'm really excited about it. gonna add getting rid of that package description thing to #282 since we (cc/ @jefflembeck @aredridel ) are planning on getting rid of that pesky readme + desc weirdness anyways

omg 10.0.0 is gonna be so good

@ashleygwilliams
Copy link
Contributor

ok! travis is FINALLY green lol. mergin'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants