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

[rustdoc] Convert double-hyphen to dash in docs #64081

Closed
alexreg opened this issue Sep 2, 2019 · 15 comments · Fixed by #112205
Closed

[rustdoc] Convert double-hyphen to dash in docs #64081

alexreg opened this issue Sep 2, 2019 · 15 comments · Fixed by #112205
Labels
A-markdown-parsing Area: Markdown parsing for doc-comments C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@alexreg
Copy link
Contributor

alexreg commented Sep 2, 2019

It would be nice to get rustdoc to convert double-hyphen (--) (probably just when surrounded by spaces?) to a dash character () in doc-comments. People tend to use double-hyphen in code instead of the actual actual character, since it's easier to type on most keyboards. I reckon this could be done perfectly reliably.

@alexreg alexreg added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 2, 2019
@GuillaumeGomez
Copy link
Member

Do you have an example of where it'd be useful? In such cases, I'm afraid of side-effects of unwanted replacements or maybe users' misunderstanding.

@alexreg
Copy link
Contributor Author

alexreg commented Sep 2, 2019

Well, it's just about nicer typography. See the rustc guide for example. What side effects do you imagine? The main one I can envisage is --command-line-options, but they should always be in backticks, I'd think... and you use a Markdown parser anyway, so I think it's okay.

@GuillaumeGomez
Copy link
Member

So still doesn't sell much of a dream: ;)

@alexreg
Copy link
Contributor Author

alexreg commented Sep 2, 2019

Oh I know, the benefit is incremental... but the implementation cost is so low, and I don't see the downside. ;-)

@alexreg
Copy link
Contributor Author

alexreg commented Sep 2, 2019

I mean... don't we all like nice, propr typography?

@GuillaumeGomez
Copy link
Member

Install a better font maybe? 😛

@alexreg
Copy link
Contributor Author

alexreg commented Sep 3, 2019

This is nothing to do with fonts... it's to do with vs. --!

@ollie27 ollie27 added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Sep 4, 2019
@ollie27
Copy link
Member

ollie27 commented Sep 4, 2019

I'm assuming you mean converting a pair of hyphen-minus characters into an en dash like in TeX?

rustdoc uses CommonMark and unless this was added to that spec I don't think it's worth adding this feature. It's already possible to insert en dashes using – for example.

@alexreg
Copy link
Contributor Author

alexreg commented Sep 4, 2019

@ollie27 Yes, I wrote it correctly in my title and the wrong way round in the comment oops. I think this is really orthogonal to Markdown to be honest... Sure, it's already possible, but no one is going to write %ndash; in doc-comments, that's the problem. We might as well accept the convention and just aim for better typographical display.

@Ixrec
Copy link
Contributor

Ixrec commented Sep 8, 2019

People tend to use double-dash in code instead of the actual hyphen character, since it's easier to type on most keyboards.

I think this is simply incorrect: it's the em dash [—] that I'm trying to emulate when I use a double hyphen [--], not a single hyphen [-] (or an en dash [–] for that matter). Obviously "the actual hyphen character" is easy to type, since a double hyphen is literally just typing it twice.

But assuming that was just terminology confusion, auto-converting a double hyphen to an em dash makes a lot of sense to me, and I feel like I've encountered this behavior in other tools before without complaint. Though it also seems reasonable to move this question to the CommonMark spec, since it probably ought to be done in all markdown-processing tools.

@alexreg
Copy link
Contributor Author

alexreg commented Sep 8, 2019

@Ixrec

  1. That was was just me accidentally writing them the wrong way round (I had written it correctly earlier, oops!).
  2. The en/em-dash is definitely not easier to type on most keyboards (which don't have it) and OSs. On Windows you need an Alt+code combination, and on macOS you need Alt + Shift + - for the em-dash! Double-tapping the same key twice is a lot easier, I'm sure.
  3. Glad you think the behaviour itself is useful. I agree it would probably make sense to become a part of CommonMark, but I don't think it needs to for us to implement it here. But I'll file an issue there anyway; good idea.

@alexreg
Copy link
Contributor Author

alexreg commented Sep 8, 2019

Ah, seems there's already an "optional extension" to the spec, but it has -- meaning en-dash and --- meaning em-dash, which is slightly awkward I think. (In practice, en-dash is encountered much less often, I find, since it used primarily for ranges, and the typographic difference from hyphen is less noticeable.)

commonmark/commonmark-spec#593

@steveklabnik
Copy link
Member

rustdoc uses CommonMark and unless this was added to that spec I don't think it's worth adding this feature. It's already possible to insert en dashes using – for example.

This is my opinion as well.

@alexreg
Copy link
Contributor Author

alexreg commented Sep 9, 2019

@steveklabnik See my above comment. It's an optional extension already part of the spec, according to that thread. :-)

@jyn514 jyn514 added the A-markdown-parsing Area: Markdown parsing for doc-comments label Nov 12, 2020
@pacak
Copy link
Contributor

pacak commented May 29, 2023

Unless I'm mistaken rustdoc now uses pulldown-cmark which performs this transformation. Transformation is performed inconsistently - only in blocks it considers to be markdown. This makes generating documentation in markdown with extra html styling complicated enough to the point it's easier to generate just html.

Either way this ticket seems to be completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-markdown-parsing Area: Markdown parsing for doc-comments C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants