Skip to content

Line numbers in code snippets #583

Open
@swagatata

Description

@swagatata

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

Activity

AndrewDiMola

AndrewDiMola commented on Jul 6, 2022

@AndrewDiMola
Contributor

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.

Wilfred

Wilfred commented on Jul 11, 2022

@Wilfred
Contributor

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

AndrewDiMola

AndrewDiMola commented on Jul 11, 2022

@AndrewDiMola
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Wilfred@swagatata@AndrewDiMola

        Issue actions

          Line numbers in code snippets · Issue #583 · hhvm/user-documentation