Closed stevenle closed 3 years ago
I think those additional arguments were intended to be internal. What are you using them for?
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?
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.
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.
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: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52752