Avoid Screenshots of Text/Code

Why avoid Screenshots of Text/Code?

I dislike screenshots of text, because they are:

  1. less accessible (text can be read via screen-readers, or braille displays)
  2. less searchable (text recognition tools often aren’t easily available / not well integrated or may contain faults in their output)
  3. annoying (you can’t easily/reliably copy the text out of a screenshot)

I think these are good reasons to keep the amount of screenshots of text low in the forum and only use them, when it can’t be avoided or if there is a good reason to use a screenshot of text, for example when you are explaining something with additional annotations like in this example: Initial implementation of `zig build --watch` just landed in master branch - #4 by andrewrk

How do I highlight my Text/Code?

To post code you can use:

```
your_code_here
```

You also can select your code and press ctrl+e, this works both for inline and multi-line code snippets.

If your code is in a specific language you can add the language to a multiline code block:

```python
def factorial(x):
    if x <= 1:
        return 1
    return x * factorial(x - 1)
```
def factorial(x):
    if x <= 1:
        return 1
    return x * factorial(x - 1)

Often adding the language isn’t strictly necessary, because highlight.js (which is used by discourse) has language detection features, however if you want to make sure that the language is specifically and accurately recognized you can add it explicitly. This forums default language is zig, unless highlight.js recognizes the code as a different language.

These are the supported languages of highlight.js, only the ones not listing a package are part of the default distribution of highlight.js and thus should be bundled with discourse’s highlight.js, however not all of those may be activated in the site-setting of this discourse instance (forum), but you can ask whether we can activate those.

Additionally we have manually added highlight support via a theme component, that adds Zig highlighting.

What are your reasons for using Screenshots?

If the reason is mostly not knowing that these highlighting options exist, please try out whether your highlighting is supported and if it works please convert your screenshot to highlighted text.

If it isn’t and you think your highlight language is used commonly enough in this forum to warrant highlight support, you can request it here and we can look into it.

Of course there are sometimes good reasons for using screenshots, this is mostly about keeping to a minimum the amount of screenshots that don’t have a good reason.

That said, I want to hear the reasons from people why they feel like using a screenshot was better in some situations, are there missing features from the forum, do we need to tweak syntax highlighting, etc?

14 Likes

I completely agree that code should (almost) never be posted as a screenshot. As someone who has made his first post today, I noticed that the option to insert code or format the text as code does not show in the little element that shows other tips like bold, italic or hyperlinks.

tl;dr: In my opinion, since this is a forum for Zig-programming. The code-format option should be easily available in the menu bar!

It is there but it is called “Preformatted Text” </>

codebutton