Html : Insertar códigos en html con SyntaxHighlighter

NC > Computación > HTML

Agregar :
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" 
  rel="stylesheet" type="text/css"></link >
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" 
  rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" 
  type="text/javascript"></script>

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" 
  type="text/javascript"></script>

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" 
  type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js" 
  type="text/javascript"></script>

<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" 
  type="text/javascript"></script>

Luego:
<script type="text/javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

Ejemplo en java:
<pre class="brush: java">public class Main{
  public static void main(String arg[]){
    System.out.println("Hola mundo");
  }
}
</pre>
Y se muestra:
public class Main{
  public static void main(String arg[]){
    System.out.println("Hola mundo");
  }
}

Ejemplo en python:
<pre class="brush: python">
a = 1
suma = 0
while a <= 7
    b = b + 1
print b
</pre>

Y se muestra:
a = 1
suma = 0
while a <= 7
    b = b + 1
print b

Para agregar solo un lenguaje, por ejemplo Java:

Agregar :
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>

Luego:
<script type="text/javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

Por último, ejemplo en java:
<pre class="brush: java">public class Main{
  public static void main(String arg[]){
    System.out.println("Hola mundo");
  }
}
</pre>

Y se muestra:
public class Main{
  public static void main(String arg[]){
    System.out.println("Hola mundo");
  }
}

Links:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. http://blog.renesilva.net/tips/syntax-highlighter-para-blogger/
  3. http://dasubipar.blogspot.com/2011/11/mostrar-codigo-fuente-en-entradas-de.html
  4. http://stackoverflow.com/questions/10335463/how-to-setup-syntax-highlighter-on-blogger
0.14

No hay comentarios.:

Publicar un comentario