Marking up code blocks for unsupported languages #170
-
What should our rules be for marking up code blocks when the languages are not one of the supported set (as listed in https://github.com/mdn/yari/blob/main/build/syntax-highlight.js#L15). Options:
The ideal would be to do "1" but it isn't clear what the cost of adding a new language is. If it is a per-page cost then you'd reasonably just add all the languages, whereas if the cost applies to every page, you'd have to consider pages separately. Haven't got an answer on how this works - trying in mdn/yari#6763 Either way, currently I use "3" because really, the syntax for all the shells is much the same (so you get some benefit using bash for command, powershell, etc etc.). But I'm leaning towards suggesting we use "4"). Why? My assumption is that this is the best future proofing and indication of intent. It can't be wrong, and it should all work nicely if we were to add linters for different language types later on. [Note, posted this because of https://github.com/mdn/content/pull/19259 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
Considering that the file for importing and loading Prism is in the |
Beta Was this translation helpful? Give feedback.
-
Whatever we do, please let's document the identifiers that authors should be allowed to use, and update the list when there is a need for more. We currently do this here: https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Howto/Markdown_in_MDN#example_code_blocks. I'm not really in favour of people being able to add whatever identifiers they feel like. There isn't a cost to readers in this but there is a cost to maintainers. |
Beta Was this translation helpful? Give feedback.
-
So according to @queengooborg adding a language is virtually zero-cost for the user. In this case I don't see any reason why we can't mark up all code blocks with the right language. In my editor, the code will be displayed with the corresponding syntax highlighting; for static analysis tools (not just limited to JS linters), they will be able to grep all code blocks to be linted; for users, they enjoy richer syntax highlighting, or failing that, at least with no adverse effects. I'm going towards "4". We should do the following:
I don't have strong opinions on telling people what language should be allowed to use. If we have a diverse language set to start with, that definitely works. What I don't want is for people to work around the platform limitations and mark up powershell code blocks as bash. |
Beta Was this translation helpful? Give feedback.
-
The consensus appears to be:
++The "non-spurious" reason should be pretty lax. I just want PR reviewers to have a right to reject PRs where no thought has gone into adding the language. Should we have "Fortran"? Maybe, but not because someone decides it might be fun. |
Beta Was this translation helpful? Give feedback.
The consensus appears to be: