It is arguable that the question you reference as being on-topic is actually
an off-site resource request and should be closed as such. Interestingly, your question doesn't actually seem to be an off-site resource request; However, your question is still off-topic for multiple other reasons.
You're actually asking two different questions: a how-to question, and a debugging question, so I'm going to split them up.
The How-To Question:
There is a page on GitHub Help describing how to use
syntax-highlighted code blocks. On that page there are instructions
describing how to match languages to their keywords for this purpose:
We use Linguist to perform language detection and syntax highlighting. You can find out which keywords are valid in the
languages YAML file.
However, there's a lot of data in that YAML and I don't find it very
clear how exactly one can use it to determine which keywords work for
any given language.
...
There are already some questions about this on Stack Overflow; an
answer to one mentions something called Pygments, while an
answer to another mentions something called Garrett Flavored
Markdown. I'm skeptical about both of these; I can't tell whether
either of them are related to the Linguist library linked from the
Help page. In any case, all existing questions only ask for ways to
find a valid keyword for a given language, not all valid keywords.
What I'm looking for is a way to get something like the list of
language codes for Stack Exchange syntax highlighting, but for
Markdown on GitHub. How can I get such a list?
There are two ways this question can go and both are too broad the way the question is currently written; either:
You actually just want the list.
Such a question would unequivocally not fit the Stack Exchange format, and would most likely never be allowed. If it were allowed to exist, it would have to be maintained any time the original list is changed, and I imagine there would be semi-regular meta arguments about such a post.
You want a solution to generate such a list programmatically.
This is too broad for two main reasons:
- You haven't specified a language, you've only specified an output language (JSON). You haven't even specified the format of the output (the format can largely be assumed, but that is open for interpretation so it isn't helping you).
Given the requirements of the current question, this is too broad to ever be useful to future viewers. You want to generate such a list from a very specific input, and no one else is going to want to generate the same output from that input.
If you split up this task into its component parts, you get:
- You need to parse the YAML using whatever programming language you pick to work with.
- You need to interpret that parsed data into another format
- You need to output the data to the client
Ultimately, you can probably figure out how to parse the YAML using whatever programming language you pick to work with, and how to output the data to the client. This leaves you with the important question of how to interpret the parsed data into another format.
Now you want have the makings of a reasonable how-to style question. To give your question the best chance possible, you're going to want to cut down on any ambiguities or uncertain terms, as well as cutting down on the application specific requirements that don't really matter.
To do this, I'd recommend the following:
- Figure out what language you're going to use.
- Generate a generic example representing the parsed data that removes anything application specific and is as basic as possible while still representing the actual structure of the real data.
- Figure out the exact output structure you want, and lay that out as simply as possible using a short description of the relationship between the input and the output, as well as an example of the output you would expect to be generated from the example input.
- List all requirements clearly and concisely, removing any requirements that are not absolutely necessary.
- Be sure to clearly and concisely ask how to go about getting the expected output from the example input while abiding by the minimal requirements that you've worked out.
Once you've done all of that, you may find yourself the proud owner of an on-topic how-to style question.
The Debugging Question:
I wrote a simple boot to attempt to parse this YAML to a
more readable JSON file mapping from each language to its list of
valid keywords:
curl https://raw.githubusercontent.com/github/linguist/f75c5707a62a3d66501993116826f4e64c3ca4dd/lib/linguist/languages.yml
| ./languages.boot > languages.json
But I'm not at all convinced that this is correct. For instance, many
of the keywords that my script produces include spaces, and I was
under the impression that those would not work:
The content of a code fence is treated as literal text, not parsed as inlines. The first word of the info string is typically used to
specify the language of the code sample, and rendered in the class
attribute of the code
tag.
This question is off-topic for most of the reasons listed under the "Debugging/No MCVE" close reason:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.
Your question does include the desired behavior and a specific problem (specificity arguable), but it does not include:
- The shortest code necessary to reproduce it (in the question itself).
- Example input (in the question itself).
- Expected output.
Namely, it does not include an MCVE.
If you were to edit the question to include an MCVE in the question itself which were to actually abide by the guidelines set forth in How to create a Minimal, Complete, and Verifiable example (i.e. not a huge code dump, nothing application specific that is unnecessary, etc.), then you may end up with an on-topic debugging style question.