curriculum icon indicating copy to clipboard operation
curriculum copied to clipboard

Make sure all code snippets use language tags

Open loopiezlol opened this issue 6 years ago • 7 comments

This also applies to code snippets in footnotes, revisionQuestion, practiceQuestion, not only content.

All code snippets should have language tags:

``` -> not cool
```javascript -> cool

At the moment I've applied a hack that will put these by default to bash if they lack one. However, we need to fix these,

loopiezlol avatar Mar 20 '18 11:03 loopiezlol

I've started to insert tags for some of the code snippets and I stumbled on a few, that look like this:

'''java $ jconsole It's inside the Java section, but it's not a Java snippet. Is it still supposed to say java, due to the category it's in or is it supposed to say shell, bash or something like that?

Also: Most of the exercises do not have tags, are they supposed to have them as well?

(If there is a documentation on this, that I missed, I'm happy to have a look there. :) )

mardapol avatar Apr 02 '18 11:04 mardapol

I have a followup question for you, @Loopiezlol, for some (relatively frequent) edge cases:

How should code blocks be tagged that aren't in any programming language? Some examples are:

  • Example output printed to the console (e.g. "Hello, world!")
  • Simple diagrams using text (there are many of these in the Comp. Sci. section)

Another class of special cases would be things like the revision question in the Python insight Indentation and Commenting. This asks the user to identify the correct commenting syntax, but syntax highlighting would give the answer away rather than relying on the user's understanding of the syntax. For this specific code block, I would want to intentionally omit a language tag.

Would text be a good "language" to specify for these types of cases to show that the choice was intentional, as opposed to not specifying a language at all?

noahbrenner avatar May 01 '18 06:05 noahbrenner

@lizTheDeveloper, any thoughts on the questions that Marvin and I asked here?

noahbrenner avatar Jun 17 '18 19:06 noahbrenner

@noahbrenner, @MarvinPollock these are good points. I would tend to agree that we would actually need generic code block elements that aren't syntax highlighted (and you both gave good examples).

I think we might need to stay with our fork of remark-stringify @Loopiezlol and update the code visitor to stringify with backticks

nem035 avatar Jun 17 '18 23:06 nem035

@nem035 it is also true that there are a ton of code blocks that should have language tags but don't currently.

Would it make any sense to define a specific language tag that means "no highlighting"? That could make the source files easier to lint, since any block without an explicit language tag would clearly be incorrect. There wouldn't be a question every time as to whether a language tag was just forgotten or if it was intentionally omitted.

Since there are a number of existing code blocks marked with text as the language, that could be a good choice (if you go that route), since there are a decent number of existing code blocks that already align with that usage.

noahbrenner avatar Jun 17 '18 23:06 noahbrenner

@noahbrenner true, using a designated tag like text for this would also work. That also might be the simplest solution. I like it. Let's see what @Loopiezlol and @lizTheDeveloper think about it.

nem035 avatar Jun 17 '18 23:06 nem035

Any updates on this topic? It would be great to know the official preferred way of handling these types of code blocks.

noahbrenner avatar Jul 30 '18 03:07 noahbrenner