Page 1 of 1

Syntax Highlighting is back!!!

Posted: Mon May 05, 2014 10:14 pm
by satoon101
We just added back in syntax highlighting. Currently available languages are:

  • PYTHON
  • CPP
  • INI
  • BASH
  • WINBATCH
  • XML
  • MAKE
  • ASM
  • PHP
  • JS
  • CSS
  • HTML
  • JAVA
  • SQL
  • TCL

You use them by using the names listed above like [PYTHON]<code>[/PYTHON]

Test block:

Syntax: Select all

def test(args):
'''Test function'''

# Test comment
print('Hello World')

Posted: Mon May 05, 2014 10:24 pm
by L'In20Cible
What a nice feeling to my eyes!!!

Posted: Tue May 06, 2014 7:21 am
by La Muerte
Well done :D

Posted: Tue May 06, 2014 4:03 pm
by Ayuto
Great!! :)

Posted: Tue May 06, 2014 10:46 pm
by L'In20Cible
Just noticed an issue, tho. Every 55 characters, there is 2 extra spaces added into Python blocks. Example here. If you go into Edit Mode, you will see the code is correct but there is extra spaces when displayed.

Posted: Tue May 06, 2014 11:27 pm
by satoon101
I noticed this earlier today. Not sure how to fix it, but we'll look into it. For now, you can just try to not make the line go longer than 55 characters.

Posted: Mon May 12, 2014 9:00 pm
by Doldol
Nice!! But It'd be awesome if tabs either had a width of 4 spaces or were converted into 4 spaces, currently tabs are 8 spaces wide (at least on my browser).

I know this project prefers 4 tabs, but I personally really like tabbed indentation. Hehe.
Converting a tab into 4 spaces would be better in case you'd really want to keep consistency anyway.

It's not important, but just a suggestion. :)

Syntax: Select all

def test():
"1tab"
"4spaces"

Posted: Wed Jul 30, 2014 8:26 am
by satoon101
Just created a new "pastebin" bbcode. Just use the paste's url to show the code. Of course, if the code expires, it will disappear at that time.

Example:

[pastebin]B1txGZ66[/pastebin]

One issue with it is that I can either set the height to 100% and it can create very long posts, or I can set it to a fixed height. If I set it to a fixed height, any pastes that are shorter will still take up that much space with just blank space before anything else in the post. For now, I have it set to 100%.

I believe there is a way to use pastebin's syntax highlighting API on your own site, as well. I am checking into this.

Posted: Wed Jul 30, 2014 9:35 am
by La Muerte
You could just keep it as it is now and add something like following css code:

Code: Select all

.embedPastebin .python {
max-height: 80px;
overflow-y: scroll;
}

Posted: Thu Aug 28, 2014 11:44 am
by Ayuto
Could you also add ASM highlighting? :)

Posted: Sat Aug 30, 2014 1:18 am
by satoon101
I will look into that when I get the chance (maybe tonight if I have time).


*Edit: Done :) (found this example code via google search)

Code: Select all

An implementation of SLIP (Serial Link IP), RFC 1055 in assembly language

; slip.asm
;
; This is an 8086+ implementation of SLIP (RFC 1055)
;
; It may be assembled using Microsoft's MASM using the command line:
;   ml -Fl -c slip.asm
;
; or using Borland's TASM using the command line:
;   tasm -la -m2 -jLOCALS slip.asm
;
        .model small
        .stack 100h
        .data
SLIP_END        equ 0C0h
SLIP_ESC        equ 0DBh
SLIP_ESC_END    equ 0DCh
SLIP_ESC_ESC    equ 0DDh

; note that these are both sample macros and are very simple
; In both cases, DX is assumed to already be pointing to the
; appropriate I/O port and a character is always assumed to
; be ready.
SEND_CHAR macro char
        IFDIFI <char>, <al>
                mov al,char
        ENDIF
        out dx,al
endm

RECV_CHAR macro
        in al,dx
endm
        .code
;****************************************************************************
; send_packet
;
; sends the passed packet (which is in a memory buffer) to the output
; device by using the macro SEND_CHAR() which must be defined by the
; user.  A sample SEND_CHAR() is defined above.
;
; Entry:
;       DS:SI ==> raw packet to be sent
;       CX = length of raw packet to be sent
;       direction flag is assumed to be cleared (incrementing)
;
; Exit:
;
;
; Trashed:
;       none
;
;****************************************************************************
send_packet proc
        push cx
        push si
        SEND_CHAR SLIP_END      ; send an end char to flush any garbage
        jcxz @@bailout          ; if zero length packet, bail out now
@@nextchar:
        lodsb                   ; load next char
        cmp al,SLIP_END         ; Q: is it the special END char?
        jne @@check_esc         ;  N: check for ESC
        SEND_CHAR SLIP_ESC      ;  Y: send ESC + ESC_END instead
        mov al,SLIP_ESC_END     ;
        jmp @@ordinary          ;

@@check_esc:
        cmp al,SLIP_ESC         ; Q: is it the special ESC char?
        jne @@ordinary          ;  N: send ordinary char
        SEND_CHAR SLIP_ESC      ;  Y: send ESC + ESC_END instead
        mov al,SLIP_ESC_ESC     ;
        ; fall through to ordinary character

@@ordinary:
        SEND_CHAR al            ;

        loop @@nextchar         ; keep going until we've sent all chars
@@bailout:
        SEND_CHAR SLIP_END      ; send an end char to signal end of packet
        pop si
        pop cx
        ret
send_packet endp

;****************************************************************************
; recv_packet
;
; receives a packet using the macro RECV_CHAR() which must be defined by
; the user and places the received packet into the memory buffer pointed
; to by ES :D I.  The final length is returned in BX.
;
; Note that in the case of a buffer overrun, the portion of the packet
; that fit into the buffer is returned and BX and CX are equal.  There
; is no way to tell the difference between a packet that just exactly
; fit and one which was truncated due to buffer overrun, so it is
; important to assure that the buffer is big enough to ALWAYS contain
; at least one spare byte.
;
; A sample RECV_CHAR() is defined above.
;
; Entry:
;       ES :D I ==> packet buffer
;       CX = length of buffer
;       direction flag is assumed to be cleared (incrementing)
;
; Exit:
;       BX = length of packet received
;
; Trashed:
;       none
;
;****************************************************************************
recv_packet proc
        push cx
        push di
        xor bx,bx               ; zero received byte count
        jcxz @@bailout          ; if zero length packet, bail out now
@@nextchar:
        RECV_CHAR               ; fetch a character into al
        cmp al,SLIP_END         ; Q: is it the special END char?
        jne @@check_esc         ;  N: check for ESC
        or  bx,bx               ;  YQ: is it the beginning of packet?
        jz @@nextchar           ;   Y: keep looking
        jmp @@bailout           ;   N: end of packet, so return it

@@check_esc:
        cmp al,SLIP_ESC         ; Q: is it the special ESC char?
        jne @@ordinary          ;  N: it's an ordinary char
        RECV_CHAR               ;  Y: get another character
        cmp al,SLIP_ESC_END     ;  Q: is it ESC_END?
      jne @@check_esc_esc      ;   N: check for ESC_ESC
        mov al,SLIP_END         ;   Y: convert to ordinary END char
        jmp @@ordinary          ;
@@check_esc_esc:
        cmp al,SLIP_ESC_ESC     ;  Q: is it ESC_ESC?
        mov al,SLIP_ESC         ;   Y: convert to ordinary ESC char
        ; protocol violation! fall through to ordinary character

@@ordinary:
        stosb                   ; store character in buffer
        inc bx                  ; got another char
        loop @@nextchar         ; keep going until we've sent all chars
@@bailout:
        pop di
        pop cx
        ret
recv_packet endp
        END

Posted: Sat Aug 30, 2014 7:05 am
by Ayuto
Awesome! Thank you!! :)