RaspberryPiFoundation / lesson_format

Lesson formatter
17 stars 28 forks source link

Syntax highlight python code blocks #158

Closed andylolz closed 9 years ago

andylolz commented 9 years ago

This big code block here is hard to read: http://projects.codeclub.org.uk/en-GB/05_python/05/Gameshow.html#activity-checklist

Look how much nicer it is with just some subtle syntax highlighting:

from random import *

#print the 3 doors and the game instructions
print('''
Gameshow!
=========

There's a prize behind one of the 3 doors!
Guess the correct door to win the prize!
  _____   _____   _____
 |     | |     | |     |
 | [1] | | [2] | | [3] |
 |   o | |   o | |   o |
 |_____| |_____| |_____|

Choose a door (1, 2 or 3):
''')

#get the chosen door and store it as an integer (whole number)
chosenDoor = input()
chosenDoor = int(chosenDoor)

#randomly choose the winning door number (between 1 and 3)
winningDoor = randint(1,3)

#show the player the winning and chosen door numbers
print("The chosen door is", chosenDoor)
print("The winning door is", winningDoor)

#player wins if the chosen door and winning door number are the same
if chosenDoor == winningDoor:
    print("Well done!")
else:
    print("Unlucky!")

It’s trivial to do this client-side, and there probably exists something to do it in pandoc.

andylolz commented 9 years ago

So I think this relies on codeclub/python-curriculum#51 (to ensure pandoc generates the correct html) and then it’s just a case of including some highlighting-kate css or sass.

andylolz commented 9 years ago

Fixed in 814c4821.