enkidevs / curriculum

👩‍🏫 👨‍🏫 The open-source curriculum of Enki!
https://www.enki.com/mobile-app
Other
793 stars 1.16k forks source link

Make sure all code snippets use language tags #654

Open loopiezlol opened 6 years ago

loopiezlol commented 6 years ago

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,

mardapol commented 6 years ago

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. :) )

noahbrenner commented 6 years ago

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:

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 commented 6 years ago

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

nem035 commented 6 years ago

@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

noahbrenner commented 6 years ago

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

nem035 commented 6 years ago

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

noahbrenner commented 6 years ago

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