Skip to main content

Formatting Text as Code Using Markdown

Use Markdown to format text and preserve code styling in your custom quizzes.

Written by Mary Duskwood
Updated over 2 months ago

Banner: Free feature

In custom quizzes, you can format text as code by using the in-line Markdown formatting tags. This also works when leaving feedback or comments for students in the conversation tab. (Note: Markdown isn't supported in custom exercises/activities, only custom quiz assignments)

See below for a list of these common formatting options:


Code and Syntax Highlighting

Inline code:

To apply formatting inline, you can wrap text in backticks `

  • Example input:

    • `takeBall()`

  • Code output:

    • takeBall()

Blocks of code:

If you would like to apply formatting for code blocks, you can use three backticks and indicate the language for syntax highlighting.

JavaScript:

  • Example input:

```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```
  • Code output:

Image showing text with styling applied

Python:

  • Example input:

```python 
s = "Python syntax highlighting"
print s
```
  • Code output:

Image showing text with styling applied

No Language Specified:

Note--if you do not specify the language, no syntax highlighting will appear.

  • Example input:

``` 
No language indicated, so no syntax highlighting.
```
  • Code output:

No language indicated, so no syntax highlighting.

Headers

  • Example input:

# H1 example text
## H2 example text
### H3 example text
#### H4 example text
##### H5 example text
###### H6 example text
  • Code output:

    Image showing H1-H6 formatting applied to text

Alternate H1/H2 Header with Horizontal Rule

  • Example input:

Alt-H1 
======

Alt-H2
------
  • Code output:

Image showing text with styling applied

Links

  • Example input:

[Clickable text for inline-style link](https://www.codehs.com)

[Clickable text for link with a title](https://www.codehs.com "CodeHS Homepage")
  • Code output:

gif showing text with styling applied

Images

  • Example input:

![alt text](https://static.codehs.com/img/program_icons/karel.png "CodeHS Logo")
  • Code output:

Animated .gif showing the flow of editing quiz question text using markdown

Emphasis

  • How to use emphasis:

    • Italics: wrap text in *asterisks* or _underscores_

    • Bold: wrap text in double **asterisks** or __underscores__

    • Combined: wrap with: **asterisks and __underscores__**

    • Strikethrough: wrap text in two tildes: ~~example text~~

  • Example input and code output:

    Gif showing markdown in plan text and when formatting is applied

More info on Using Markdown: Markdown Guide


Still have questions? Contact our team at support@codehs.com to learn more!

Did this answer your question?