user-documentation icon indicating copy to clipboard operation
user-documentation copied to clipboard

Line numbers in code snippets

Open swagatata opened this issue 5 years ago • 3 comments

Please complete the information below:

Where is the problem?

Code examples.

      • eg "The section describing how widgets work" - - -

What is the problem?

In the code examples, the errors show line numbers but the code itself is shown without line numbers. It would be much clearer if the line numbers were present to identify the source of the errors.

      • eg "It doesn't explain that widgets are singletons" - - -

Please don't change anything below this point.


  • Build ID: 2019-02-14T15:43:02+0000:295af88d1de39887aa1dab1972d18d2d4a460f14
  • Page requested: /hack/types/introduction
  • Page requested at: Thu, 07 Mar 2019 14:12:57 +0000
  • Controller: GuidePageController

swagatata avatar Mar 07 '19 14:03 swagatata

We could probably add that code here: https://github.com/hhvm/user-documentation/blob/main/src/markdown-extensions/PrettyCodeBlocksFilter.php#L45.

Looks like the code string is split by lines into a vec. Maybe we could append a number if the code sample is at least two lines long and then put it back together in the join.

AndrewDiMola avatar Jul 06 '22 17:07 AndrewDiMola

@AndrewDiMola this should probably be done in CSS. We don't want to break copy-and-paste for code snippets.

Wilfred avatar Jul 11 '22 18:07 Wilfred

@AndrewDiMola this should probably be done in CSS. We don't want to break copy-and-paste for code snippets.

Oh, I didn't even think about that. Good point.

AndrewDiMola avatar Jul 11 '22 19:07 AndrewDiMola