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

Multi color highlighting #213

Open
awdeorio opened this issue Sep 26, 2022 · 5 comments
Open

Multi color highlighting #213

awdeorio opened this issue Sep 26, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@awdeorio
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Explaining a larger code block is tricky. While highlighting is very helpful when there's one key point, it falls short when you have several points. For an example, see the EECS 485 P4 Sockets and waiting example and explanation.

Describe the solution you'd like
It would be nice if I could highlight several different ranges of lines in several different colors. Then, in the text use some kind of visual clue to refer to the different colors in different paragraphs of the explanation.

Describe alternatives you've considered
The current explanation copy-pastes a few lines at a time. This is less than ideal because the blocks are out of context.

I've also considered referring to line numbers. While this is accurate, it's a little harder to read from the student perspective.

Additional context
I'm very open to suggestions here. Are there other better ways to explain more complex chunks of code?

@awdeorio awdeorio added the enhancement New feature or request label Sep 26, 2022
@seshrs
Copy link
Member

seshrs commented Sep 26, 2022

Thanks for the feedback! Yes, I definitely see the issue with explaining large codeblocks.

I’m hesitant about whether multi-color highlighting is the best solution though, especially from the point-of-view of accessibility (for students with color vision deficiencies).

Instead, what do you think about “callouts” that appear inside the codeblock and appear in the margin or to the right of the code? I’ll need to look for examples on other websites and give some thought to the API…

@seshrs
Copy link
Member

seshrs commented Sep 26, 2022

Ah ha, found an example of “annotations”: https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#adding-annotations

Though I think I’d choose a slightly different API, and make it possible to add multi-line annotations.

Aside: I also really like Docusarus’ implementation of “magic comments” for highlighting ranges. I think I can implement that too! https://docusaurus.io/docs/markdown-features/code-blocks#highlighting-with-comments

@awdeorio
Copy link
Contributor Author

Thanks for pushing back with better suggestions!

Ah ha, found an example of “annotations”

So basically pop-ups inline with code. One downside is that it might not be obvious that you should read this.

magic comments” for highlighting ranges.

Is the idea that you click something to change which lines are highlighted? That's cool! You could show 1 block of code. Show default (first) highlighting. Explain it in the following paragraph. Then in the next paragraph say "now we're talking about this other chunk. There's a link that causes the highlighting to shift.

@seshrs
Copy link
Member

seshrs commented Sep 27, 2022

Is the idea that you click something to change which lines are highlighted?

Oh hmm, I hadn’t thought about that. I’ll need to think a bit more about that one.

Regarding magic comments, I was referring to using code block comments to indicate which lines should be highlighted, instead of specifying line numbers. (It would be easier for you as a spec author to see which lines are highlighted.)

@awdeorio
Copy link
Contributor Author

Regarding magic comments, I was referring to using code block comments to indicate which lines should be highlighted, instead of specifying line numbers. (It would be easier for you as a spec author to see which lines are highlighted.)

Meh, I could take it or leave it with the magic comments.

@seshrs seshrs added this to the WN 2024 milestone Oct 22, 2023
@seshrs seshrs removed this from the WN 2024 milestone Feb 5, 2024
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