-
Notifications
You must be signed in to change notification settings - Fork 29
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
Proposed exports #16
Comments
Since
It's
There's a bunch of other internal stuff that would probably have to be exposed for this (such as |
I can just do this if you want to keep
IMO it's just a bit of a surprising type, since I would normally expect this to be an enum with names for each case. The type name conveys that it's very specific to the block parsing context. Not a huge deal though.
In my use case at least, I was able to stick to the current public interface with the exception of the constructor.
For example, I have a composite block that has a "header" on the first line followed by indented blocks. Such as:
Then I have code like this that needs to parse through the header line, which involves many lookups to An alternative here would be a method like |
The code you linked seems to have already moved in the meantime. In any case, I can see the use for an abstraction to help here, but simply exporting the |
I actually would also like to see the In general, I find enums much better to use in this case, as they are a better guarantee of forwards compatibility and they improve discoverability. Although of course I can just make my own version of the enum, this enum would become outdated if a new node type was ever added to import { Type as LezerMarkdownType } from '@lezer/markdown'
type ExtendedMarkdownType = MyCustomMarkdownNodeType | LezerMarkdownType; |
For Nota, I have implemented a new syntax as a Markdown extension using the interface in @lezer-parser/markdown: https://github.com/nota-lang/nota/blob/markdown/packages/nota-syntax/lib/parse.ts
Everything worked quite well -- great job on the flexible API design! But I ran into a few cases where I needed functionality that's currently private to
markdown.ts
. I'd like to show what those cases are, and in turn propose they be exported.Type
should be exported fromindex.ts
: I needType
in order to post-process the Markdown AST. However, althoughType
is exported frommarkdown.ts
, it's not accessible through the module root. My bundler can't seem to resolveimport "@lezer/markdown/dist/markdown"
so it's not easy for me to import it from the file directly.BlockResult
should be exported: this type appears in a public interface (BlockParser.parse
), so it would be nice to name it directly.InlineContext
constructor should be exported: similar to the problems described in Line objects should maybe have a char() function equivalent to InlineContext.char() #6, I had issues dealing with relative vs. global indexes inside block parsers. My solution was to just construct anInlineContext
for a given line, use absolute indexes everywhere, and then let the context methods handle the translation to relative indexes for me. But this strategy requires access to theInlineContext
constructor, which isn't exported.If you're ok with any of these, let me know and I will put up a pull request.
The text was updated successfully, but these errors were encountered: