Instalando Syntax Highlighter - Blogger

Ya era hora de revivir este blog y darle un poco de vida a los nuevos posts que se vendrán, por lo que decidí instalarle el conocido Syntax Highlighter.

Con unos pocos minutos de google les alcanzara, pero les ahorrare el trabajo llevandolos a quien me ahorro el trabajo y le estoy muy agradecido: MATTHEW V BALL, en su blog: http://heisencoder.net

Siguiendo los pasos de este post:

http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html

pude perfectamente hacer funcionar el plug in.

 

Para utilizarlo simplemente editamos el HTML agregando estos nodos:

<pre name="code" class="SIGLA_LENGUAJE">
    código y mas código
</pre>

Donde SIGLA_LENGUAJE deberá ser reemplazado por:

Languaje Sigla
C++ cpp, c, c++
C# c#, c-sharp, csharp
CSS css
Delphi delphi, pascal
Java java
Java Script js, jscript, javascript
PHP php
Python py, python
Ruby rb, ruby, rails, ror
Sql sql
VB vb, vb.net
XML/HTML xml, html, xhtml, xslt

Agrego un ejemplo de python, de un simple encriptador:

import sys

def swap_crypt(str1):
"""
this function will encrypt/decrypt a string
"""
# change string to a mutable list of characters
list1 = list(str1)
# iterate the list with step=2
for k in range(0, len(list1), 2):
if len(list1) > k + 1:
# do a swap of groups of 2 items each in the list
list1[k], list1[k+1] = list1[k+1], list1[k]
# change list back to a string
return ''.join(list1)

filename = sys.argv[1]
file = open(filename, "r")
for linea in file.readlines():
print swap_crypt(linea)
file.close()

Comments

Popular Posts