Skip to content
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

Update method signature for getAttrs #53

Closed
wants to merge 1 commit into from
Closed

Update method signature for getAttrs #53

wants to merge 1 commit into from

Conversation

stevenle
Copy link

@stevenle stevenle commented May 9, 2021

Per the code usage, the getAttrs() method actually accepts 3 arguments. Without the correct method signature, typescript complains about the usage.

There is a similar PR created to update the typescript @types definition for this package: DefinitelyTyped/DefinitelyTyped#52752

@marijnh
Copy link
Member

marijnh commented May 10, 2021

I think those additional arguments were intended to be internal. What are you using them for?

@stevenle
Copy link
Author

I had copied out the defaultMarkdownParser to a custom parser, so that I could add support for additional tags on top of it (e.g. strikethrough). I'm realizing now that I can just do something like:

const myParser = new MarkdownParser(
  schema, 
  markdownit('default', {html: false}), 
  Object.assign({}, defaultMarkdownParser.tokens , {
    s: {mark: 's'}
  ));

It does seem odd for the defaultMarkdownParser to be able to use internal variables that are inaccessible to anyone else. Any chance this could be revisited or potentially refactored so anything available to the default parser would be accessible to all?

@marijnh
Copy link
Member

marijnh commented May 10, 2021

Any chance this could be revisited or potentially refactored so anything available to the default parser would be accessible to all?

Only if there's a specific credible use case for this—expanding the public interface is easy, but all that stuff has to be supported forever.

@stevenle
Copy link
Author

I'm gonna close this since I have a workaround for my issue. I would generally recommend, if possible, to refactor the listIsTight function to somehow not require the extra args passed to it so that defaultMarkdownParser can use the public API. Otherwise, anyone looking at the code for defaultMarkdownParser will think that that API is available (as I did) and would assume that the documentation is just out-of-date.

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

Successfully merging this pull request may close these issues.

2 participants