Making messages beautiful with Markdown

I've seen posted and had a few people send me code snippets here and there now, which have been flung at the full mercy of whatever formatting the text box chooses to inflict upon them.

Using Markdown heavily day-to-day (and for my HTB note taking), and as HTB Forums support Git Markdown standard, I wanted to highlight the following to hopefully make people's lives a little clearer and prettier.

This guide is excellent, but the section to look at in particular is code:

Using back-ticks and declaring which language you're using, means that code snippets in your comments and messages will come out beautiful, syntax highlighted, and much more comprehensible. You can also wrap single variables or function_names in back-ticks to make them stand out.

So python:


# Simple while loop
a = 0
while a < 15:
    print(a, end=' ')
    if a == 10:
        print("made it to ten!!")
    a = a + 1

Or php:

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;

To those of you that were familiar with this already, apologies. For those that weren't, enjoy making your posts and messages a bit clearer and friendlier when trying to ask for help! :)





  • Thanks for this! Definitely will come in handy. ;)


  • That was so good thank you :)

  • edited January 10

    Hmm. Let test it…

    s = "Test string"
    a = """
    Another string
    print s, a
    def a():
        return None
    var s = "JavaScript syntax highlighting";

    Tip: it becomes beautiful only after reopening the page

  • edited April 29
Sign In to comment.