-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Formatting: use markdown lists in 'one of' lists #726
Conversation
@benjie I tried to run prettier on spec couple years ago and reported few issues: I really like to use prettier but I don't want to add brittle and non obvious workarounds. |
@IvanGoncharov I saw your eariler work, that's what inspired me to put the time in. I now have prettier running fully functionally against the GraphQL spec with a very tight and carefully reviewed diff thanks to some changes to Whether or not those changes get merged, this change helps to ensure the code is output in a similar way through Markdown as it is through spec-md, which is one of the goals of I challenge the assertion that this is a "brittle and non obvious workaround"; this is part of the original Markdown spec:
And is supported by all markdown processors I know of, including prettier. It's standard markdown formatting. |
Yes. I've literally diffed the output HTML and it's identical except for a few small changes unrelated to grammar - you can read some about it in #727. However this PR isn't specifically about prettier, just like #725 wasn't. I believe it has value in its own right - it is a formatting concern rather than a grammar concern. To me it's a clear enhancement to the GraphQL spec source code - Spec text in markdown before this change: Spec text in markdown after this change: This last screenshot is clearly a lot closer to the intent. And the HTML generated by |
I don't mean at the moment I meant that I worried about prettier changing formating in future releases. As for the readability, I think code block is the closes option because it keeps indentation:
And for readability inside PRs, I personally don't want to review changes where I need to pay attention to the trailing spaces. Also, in the long run, we probably want to run some markdown linter (e.g. Vale) and we will have the same situation because it can't distinguish syntax rules from the rest of the text. |
@benjie Also what about writing experience as most of the editors don't show trailing spaces as I showed in the screenshot? |
I hear your concerns about whitespace, but it's a technical spec so I'm sure technical people can be disciplined enough to be careful with whitespace changes. When reviewing a diff, whitespace changes are shown in GitHub: When editing, whitespace can be seen via text selection:
Prettier, as far as I know, won't deliberately break the markdown rules (of which this is a fundamental one, defined before even headers are defined); but if it does then we can pin an earlier version.
I personally prefer the more markdown-native approach over the codeblock escape-hatch, but you're much more familar with the GraphQL spec than I. Formatted productions like this seem to be a minority case, most productions can wrap happily* without any change to the output HTML. As you say, it's up to @leebyron to state what he wants for spec-md.
|
To help resolve the issue raised in graphql/graphql-spec#726, this allows each line of a grid of "one of" tokens to start with a line bullet. The spec-md rendered results are equivalent, however in other tools the content should be much easier to read.
To help resolve the issue raised in graphql/graphql-spec#726, this allows each line of a grid of "one of" tokens to start with a line bullet. The spec-md rendered results are equivalent, however in other tools the content should be much easier to read.
To help resolve the issue raised in graphql/graphql-spec#726, this allows each line of a grid of "one of" tokens to start with a line bullet. The spec-md rendered results are equivalent, however in other tools the content should be much easier to read.
To help resolve the issue raised in graphql/graphql-spec#726, this allows each line of a grid of "one of" tokens to start with a line bullet. The spec-md rendered results are equivalent, however in other tools the content should be much easier to read.
I know we discussed this in person months ago, but for posterity (now that the solution is up as part of a spec-md release): While trailing space line breaks are officially part of markdown, it's one of my very least favorite features for the reasons Ivan raised. Many tools and linters actually highlight trailing spaces as an error or editors that simply remove them (mine strips trailing whitespace on file save). The fix as part of spec-md allows gridded one of productions to optionally use a bulleted list. It's not an ideal solution since the bullets could imply each row is its own entity which might be slightly confusing in raw markdown view, but the spec rendered result is the same. @benjie if you're up for reviving this one to use bullet lists instead, I think that will solve |
cde0c9b
to
8109297
Compare
8109297
to
c5aea44
Compare
@leebyron Done; and have confirmed with diff that the spec renders identically (byte for byte) on |
(Musing: I bet if Markdown had used |
Nice! Happy to see this prettier-ready |
spec-md
recently added support for bulleted "one of" productions; this PR leverages this features to make the "one of" productions render similarly in regular markdown parsers (such as GitHub's) as they do inspec-md
.This is a precursor to formatting the spec with
prettier
(since, without this formatting, prettier will remove these "significant" line breaks).Originally attempted with Markdown linebreaks, but there was significant pushback.
These whitespace changes make theone of
lists render similarly in regular markdown parsers (such as GitHub's) as they do inspec-md
.