9

Stack Overflow can highlight text in code blocks for various programming languages. Many of these languages are relevant for in-game scripting. In Minecraft resource/data/behavior packs, .json files define a lot of things these packs feature. There are also Minecraft commands in both editions - which when saved in a file are called .mcfunction files.

Stack Overflow (and "advanced" Markdown in general) does show syntax highlighting for relevant languages: JSON is directly supported, and .mcfunction can be approximated with python or bash highlighting:

markdown preview in stack overflow

Other sites like GitHub can also highlight .mcfunction files directly (probably thanks to the VSCode extension maintained by MinecraftCommands):

mcfunction syntax highlighting in GitHub

Any degree of hightlighting can help tell the difference between comments and actual commands... I have some heavily commented answers where the comments take a large chunk of the code block just to explain what's happening

this question about SNBT highlighting is also related, though several years have passed since.

With these in mind...

Is it possible to enable or implement some highlighting here on Arqade?

Per the instructions in this meta post,

Here are some examples where I think syntax highlighting would be beneficial

In addition, I would like to clarify my question is about adding syntax highlighting to the main site only, and not to this meta site.


It is possible to get mcfunction directly supported. It needs to be implemented for highlightjs. Once that's done, a request needs to be filed using this template. I found this 5 year old repository that implements mcfunction for highlightjs, but I don't know if it works, if it is up to the core repository's standards, or if it has been tested.

4
  • Relevant posts meta.stackexchange.com/questions/184108/… Commented Sep 14 at 18:10
  • I think this would be better programmed at the root of Stack Exchange and apply to all the sites, not just Arqade. Stack Overflow would also benefit from this. So I think it's better you ask for it on Stack Exchange (or Overflow)'s metas. Commented Sep 14 at 20:08
  • @xtropicalsoothing its not included on every site for performance reasons. But it IS on Stack Overflow and other tech sites because their need is high Commented Sep 15 at 0:16
  • 3
    See this Meta post. I suggest a mod adds a [status-review] tag to this post already, as these things take time. The "10 or so" (11) "posts where highlighting would be helpful" have been provided. I also suggest adding that this is not required on our meta site. Commented Sep 17 at 13:27

1 Answer 1

4

I've turned on syntax highlighting for Arqade.

In order for syntax highlighting to work at all, the related tags need to have a language set for their syntax highlighting setting. Once one is set, all posts that are tagged with such a tag will permit syntax highlighting. Moderators can edit the language used for tags by opening a tag's tag wiki and scrolling toward the bottom and using the dropdown available there to set and save a default highlight setting.

For more information, you can consult this Meta SE post about syntax highlighting. I leave the decisions about which tag should have which language highlighting by default in your capable hands.

As a quick test, I went ahead and assigned lang-py to the tag and this answer that you referenced in your initial feature request looks a lot better!


Regarding getting mcfunction into highlightjs proper... I'll ask the team that deals with highlightjs about it, but I think y'all should see how the current configuration sits with you. If it's not sufficient, I'd ask that you please make a new post and have a moderator tag it with and we'll revisit.

4
  • Thank you! Any sort of highlighting support is a big upgrade. Two questions though: first, to clarify, are all syntax highlighting turned on for all Arqade posts, or is syntax highlighting only limited to python and only within the [minecraft-commands] tag? For datapacks, for example, using json completely solves them. Second, should I mark code blocks using py or should I use the formal name mcfunction for future compatibility? Not having to bulk modify things later is great but I don't know if you can temporarily remap language tags/aliases in your implementation of highlightjs Commented Oct 6 at 19:36
  • 1
    1. If a question is tagged with a tag that has a default syntax highlighting language set, all syntax highlighting is enabled for that question and its answers. If a language is not set for a tag, then it will not render (from my understanding). Moderators can go through all of the Minecraft-related tags and set the default syntax highlighting language to be whatever works best for you. If you're writing out a code block that uses a language other than the default, you can specify the language at the top of the code block, e.g. ```json Commented Oct 6 at 19:39
  • 1
    2. I would err against setting mcfunction for now (I can't promise this is something we can add at this time). For most of these, I would leave them alone until all related tags have their default syntax highlighting set up, then adjust whatever doesn't look right by using a more apt language. For example, if minecraft-commands stays as a default lang-py, you don't need to modify any code blocks in any posts under that tag that benefit from that highlighting, because they'll be default-highlighted as a python code block. If you want it to be different, then you'd need to change it. Commented Oct 6 at 19:43
  • Got it. Looked at some of my answers which all use the ```mcfunction prefix. They all defaulted to the default set language (python), so this method seems to already be future compatible for whoever uses that prefix. Not going to change any block code for anyone else, but I will keep using mcfunction for now Commented Oct 6 at 19:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.