Python Forum

Full Version: testing syntax highlighter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Python
[shcode=python]
class Ship:
   def __init__(self, sheet):
       self.frames = strip_from_sheet(sheet, (0,0), (122,164), 4, 4)
       self.frame_index = 0
       self.update()
       
   def update(self):
       self.image = self.frames[self.frame_index]
       
   def get_event(self, event):
       if event.type == pg.KEYDOWN:
           self.frame_index += 1
       
   def draw(self, screen):
       screen.blit(self.image, (0,0))
[/shcode]

XML
[shcode=xml]
<note>
   <to>Tove</to>
   <from>Jani</from>
   <heading>Reminder</heading>
   <body>Don't forget me this weekend!</body>
</note>
[/shcode]

Bash
[shcode=bash]
#!/bin/bash
STRING="Hello World"
echo $STRING
[/shcode]

C++
[shcode=cpp]
#include <tuple>
std::tuple<int, bool, float> foo()
{
    return std::make_tuple(128, true, 1.5f);
}
int main()
{
    std::tuple<int, bool, float> result = foo();
    int value = std::get<0>(result);
    int obj1;
    bool obj2;
    float obj3;
    std::tie(obj1, obj2, obj3) = foo();
}
[/shcode]
I'm a little worried that code is only enterable through a full reply, not through the quick-reply... as it seems almost all replies will be from the quick-reply.  Also, the only choices in the wysiwyg editor are "code" and "php".  Also, shcode gives a javascript syntax error if you type in a language it doesn't know (tell it the language is "oranges", or as will most likely happen frequently, "phython").

[shcode=python]print('testing')
print("testing")[/shcode]

...also, it escapes single quotes?  That's... disconcerting...
you cant add regular code tags on the quick reply either, you would have to know the BBCode for that as well if using the quick reply.

Quote:Also, shcode gives a javascript syntax error if you type in a language it doesn't know (tell it the language is "oranges", or as will most likely happen frequently, "phython").
I wasnt aware of this either.
test
Can we mod the plugin so if there's an unrecognized language entered, it changes it to "python"? lol
There is a possibility we might not be using it at all if we cant fix the other issues with it.