Then I ran the hljs.highlightAll function on the code and pasted the highlighted (by HTML) code back into the mentoring session. The code preview works fine, but after pressing “Send”, the screen went blank. It stayed like this when I refreshed, left, and reentered the page.
How do I solve this issue and should I open this on GitHub?
This will end up using highlight.js (as that is what we use on the platform, if I remember correctly) without having to deal with the filtering of the HTML tags that may be going on with the comment processing on the platform.
IIRC (it’s been a minute), the mentoring feedback area uses GitHub Flavored Markdown for codeblocks, not <pre> tags. That means for Python you would do the following (text followed by codeblock):
It is helpful to include a docstring to let others reading your code know what the function intends to do. Suggest something like:
```python
def score(x, y):
"""Score a dart throw given coord_x & coord_y on dart board.
:param x: int or float - position on the x-axis
:param y: int or float - position on the y-axis
:return: int - score for the coordinates, given the scoring described below.
Scoring circles:
Outside radius 10: 0
Within a radius 5 - 10: 1
Within a radius 1-5: 5
Within a radius 0-1: 10
"""
distance = math.sqrt(x**2 + y**2)
if distance <= 1:
result = 10
elif distance <= 5:
result = 5
elif distance <= 10:
result = 1
elif distance > 10:
result = 0
return result```
Which would then render in the mentoring UI like (screengrab of darkmode on website):
OK, I now realized that works. Because I have always been using the “preview” feature and it never shows the colouring. Should this be a feature request?
_Below is something hidden behind a details tag, so that you can look at it when you are ready._
<details>
<summary>Spoiler warning</summary>
Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the `<details>` tag... just make sure you close `<details>` afterward.
```python
print("Hi there! I'm a code block!"); ```
</details>
will render as:
Below is something hidden behind a details tag, so that you can look at it when you are ready.
Spoiler warning
Spoiler text. Note that it’s important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag… just make sure you close <details> afterward.