-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add reference
field to LinkReference
, ImageReference
#23
Conversation
* Update description of Code * infoString => info
readme.md
Outdated
@@ -723,10 +723,16 @@ its `url` and `title` defined somewhere else in the document by a | |||
`referenceType` is needed to detect if a reference was meant as a | |||
reference (`[foo][]`) or just unescaped brackets (`[foo]`). | |||
|
|||
`reference` provides the original raw reference, if the `referenceType` is | |||
`full` and the reference differs from the `identifier`. This enables |
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.
Would it make sense to drop the case where referenceType
is full
? Although it’s not needed to create the original markdown for collapsed or shortcut references in remark, it’s one less condition in the spec?
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.
Maybe it could be useful for linting, or non-HTML and non-markdown outputs?
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.
Two thoughts:
-
I don't know how to trade-off the additional memory usage vs the overhead (conceptual and runtime) of a single if-check.
-
What I do know is that 50+ tests within the remark repository alone will need to be updated should the check for
full
and different thanidentifier
be dropped. If there is that much change within the repository, chances are high this change will affect somebody's test suite out there.
As to usefulness, this comment was not meant to be an exhaustive list. I did provide a patch for remark-stringify, so this new property is arguably useful in the generation of markdown (i.e., not just the consumption).
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.
- For the trade-off, I think that’s fine. How many references are out there really.
- For the test suite: the remarkjs repo has a script:
script/regenerate-fixtures
that updates the ASTs for all tests, and you can check the diff if it works or not. I personally don’t see the addition of a property to nodes as a breaking change. Even if someones tests break because of fixtures, I don’t thinkactual(not sure how to call it) code will break. - And usefulness: I meant that the addition of a
reference
to non-full references could potentially be useful for other things, like linting, even though we’re now discussing stringifying to markdown and html, which doesn’t need it.
If you are thinking about the linting case, shouldn't references also be captured for |
@rubys Darn, that’s true. If we’re adding a value that is the “original” version of |
Some ideas, mostly bad ones, sorted from like to dislike:
|
I was going to suggest rawIndentifier which is essentially your first choice. |
Hmm. OK. But now I’m wondering. We could add I see a value in this, even though it’s far away before it’s implemented. |
We appear to be wandering off into Yak Shaving territory. :-) I don't think we need to worry to much about a linter application requirements. An application could safely get the original source via We don't have that luxury in My leaning are to not boil the ocean, and just focus on the requirements we know. After all, in all other cases than |
I know it’s yak shaving, but it’s also fair to think about it for a day! a) is simple for now, but could stand in the way of |
@woorm: what's the verdict? |
I think I prefer What do you think? Big mistake? For the implementation, I’m partial to whether only |
…tifier. This either takes the form of a `reference` or a `definition` property.
I believe I've addressed your feedback. Note: I went with If this looks correct overall, I'll update remarkjs/remark#346 to match. I don't believe that syntax-tree/mdast-util-to-hast#22 has to change. |
* remark-parse: add label to definition, footnote definition, link reference, image reference, footnote reference * remark-stringify: use full reference if no type is set Related to syntax-tree/mdast#23. Related to syntax-tree/mdast-util-to-hast#22. Supersedes GH-346. Closes GH-363. Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Co-authored-by: Sam Ruby <rubys@intertwingly.net>
Closes GH-22. Related to GH-20. Related to syntax-tree/mdast#23. Related to remarkjs/remark#346. Co-authored-by: Sam Ruby <rubys@intertwingly.net>
Closes GH-22. Related to GH-20. Related to syntax-tree/mdast#23. Related to remarkjs/remark#346. Co-authored-by: Sam Ruby <rubys@intertwingly.net>
reference
field to LinkReference
, ImageReference
No description provided.