Code formatting shouldn't be used for emphasis on regular words. That includes technology names like "iOS", "GitHub", "C#", or any other proper nouns; they don't need any special formatting. Overuse could make your post less readable. As for what it should be used for:
Inline code formatting can be useful for:
- Micro-snippets of code (This is especially important for HTML tags or things that resemble HTML tags, since some HTML is allowed in posts and the site will try to render anything between
<
and >
)
init()
if (boolean) {
<form action="..." method="post">
<strong>
<level>
- Filenames and filepaths
readme.txt
.htaccess
C:\windows\system32
__init__.py
- Shell commands, or executable names written as you'd write them at your terminal:
git
cp file1.txt file2.txt
- Showing a URL that you don't want to render into something clickable
- Data
- form input values
- text that an algorithm will operate on
- Short errors
AttributeError: 'super' object has no attribute '__getitem__'.
Code block formatting can be useful for errors and logs, especially when:
They're meant to be in a monospaced font
01-25 22:13:18.594: DEBUG/skia(4204): xxxxxxxxxxx jpeg error 20 Improper call to JPEG library in state %d
01-25 22:13:18.604: INFO/System.out(4204): resolveUri failed on bad bitmap uri:
01-25 22:13:18.694: ERROR/dalvikvm-heap(4204): 6291456-byte external allocation too large for this process.
01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 6291456 bytes
01-25 22:13:18.694: DEBUG/skia(4204): xxxxxxxxxxxxxxxxxxxx allocPixelRef failed
They contain spacing that is lost if it isn't pre-formatted
Traceback (most recent call last):
File "x.py", line 6, in <module>
f(a=1, b=1)
File "x.py", line 4, in f
return 1 / (a+1) + 1 / (b-1)
~~^~~~~~~
ZeroDivisionError: division by zero
Just make sure to disable syntax highlighting:
```none
your logs/errors here
```
(Also consider using quote blocks instead, especially for long single-line error messages.)
Beyond these examples, use other, more suitable formatting.
So for example, don't use code formatting for:
- Emphasising words.
Use italic or bold text instead (sparingly).
- Keyboard keys.
Use the <kbd>
tag.
- Tables.
Use proper Markdown tables instead