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

Hidden lines of code? #185

Open
eecs441staff opened this issue Jun 12, 2022 · 2 comments
Open

Hidden lines of code? #185

eecs441staff opened this issue Jun 12, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@eecs441staff
Copy link

Is your feature request related to a problem? Please describe.
Often times one only wants to display several lines of code. Displaying these lines without context could confuse the reader. Displaying them with surrounding lines could lead to reader cut and pasting duplicated code. Is there a way to "hide" contextual lines of code by default but reveal them, properly formatted and syntax highlighted, with the click of a button?

Describe the solution you'd like
Like this: https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#hiding-code-lines

Describe alternatives you've considered
To show the contextual lines commented out, but then it wouldn't be properly formatted and syntax highlighted and could be confusing.

Additional context
Add any other context or screenshots about the feature request here.

@eecs441staff eecs441staff added the enhancement New feature or request label Jun 12, 2022
@seshrs
Copy link
Member

seshrs commented Jul 3, 2022

(Sorry for my delayed reply while I've been traveling!)

That's a really interesting feature request. I really like the example you linked to! A couple of my initial thoughts:

  • The example you linked to seems to assume that code blocks with never have full-line text comments. Or maybe they're doing some fancy parsing to ensure that the full code-block is syntactically valid? I'm not sure, I'd have to give it a try.
  • We are kind-of limited by the default syntax-highlighter included with Jekyll. I think we'd need to switch to an in-browser syntax-highlighter to unlock features like this.

I'll give this further thought in the coming weeks.

@seshrs
Copy link
Member

seshrs commented Aug 1, 2022

Oh this could be as easy as adding a data-hidden-lines attribute 😅

My next question: How does this affect line numbers? Maybe this feature should only be allowed with the no-line-numbers variant? I'll need to give this further thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants