Python Forum
testing syntax highlighter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
testing syntax highlighter
#1
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]
Recommended Tutorials:
Reply
#2
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...
Reply
#3
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.
Recommended Tutorials:
Reply
#4
test
Recommended Tutorials:
Reply
#5
Can we mod the plugin so if there's an unrecognized language entered, it changes it to "python"? lol
Reply
#6
There is a possibility we might not be using it at all if we cant fix the other issues with it.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020