Last Updated: January 22, 2022
·
3.482K
· aimfeld

Code blocks on GitHub and coderwall

GitHub has some cool additional markdown functionality called GitHub Flavored Markdown. When inserting code blocks in GitHub pages, messages, issues, or comments, I recommend using "fenced code blocks" instead of indentation. This makes editing and copy-pasting easier and you can use syntax highlighting in various programming languanges!

This is how you create a syntax-highlighted PHP fenced (```) code block (also works on coderwall, but currently not in the preview):

```php
class ExampleDiFactory extends DiFactory
{
    // code
}
```

On GitHub, it will display like this:

Picture

2 Responses
Add your response

I was trying to use a code fence and it was not working in the preview. Thanks for letting me know that it does not work in preview, but works when published.

over 1 year ago ·

LoL Realy usefull Share i Googled to find this Pro Tip LoL Amazing when i would run codewall i would invest the 30 min to implament javascript markdown interpreter for the preview :D

over 1 year ago ·