La macro <<code>>
La macro <<code>>
permite ponde código fuente en los artículos.
Un ejemplo simple:
<<code>> from reversion.models import Revision from .helpers import ProcessedContent class Node(models.Model): language = models.CharField(max_length=10, default='en-us') <</code>>
...mostrará:
from reversion.models import Revision from .helpers import ProcessedContent class Node(models.Model): language = models.CharField(max_length=10, default='en-us')
<<code>>
y enlaces
La macro <<code>>
no se lleva muy bien con los enlaces. Si quieres tener un enlace de código incrustado hacia algo más usa ##...##
.
Por ejemplo usa:
##[[insert|INSERT]]##
en vez de
[[insert|<<code>>INSERT<</code>>]]
o
<<code>>[[insert|INSERT]]<</code>>
Resaltado de sintaxis
La macro <<code>>
también permite el resaltado de sintaxis en un código. Añade el resaltado de sintaxis al ejemplo anterior en python así:
<<code lang=python>> from reversion.models import Revision from .helpers import ProcessedContent class Node(models.Model): language = models.CharField(max_length=10, default='en-us') <</code>>
from reversion.models import Revision from .helpers import ProcessedContent class Node(models.Model): language = models.CharField(max_length=10, default='en-us')
Texto incrustado o en bloque
Cuando se usa la macro <<code>>
con el atributo lang=
puedes especificar donde quieres el código incrustado con el texto que lo rodea o mostrarlo en un bloque. (El parseador criollo intentará adivinar que es lo que quieres si no especificas este atributo.)
Los valores válidos son true
yfalse
.
Here is some <<code lang=c inline=true>>true inline code<</code>>.
Here is some true inline code
.
Here is some <<code lang=c inline=false>>false inline code<</code>>.
Here is some
false inline code
.
Here is some <<code lang=c inline=none>>none inline code<</code>>.
Here is some
none inline code
.
Lenguajes soportados para el resaltado de sintaxis
Lenguaje | Nombre(s) corto(s) permitido(s) |
---|---|
JavaScript+Mako | js+mako, javascript+mako |
Brainfuck | brainfuck, bf |
HTML+Cheetah | html+cheetah, html+spitfire |
Bash | bash, sh, ksh |
CSS+Myghty | css+myghty |
Coldufsion HTML | cfm |
Smarty | smarty |
ApacheConf | apacheconf, aconf, apache |
Java | java |
JavaScript+Genshi Text | js+genshitext, js+genshi, javascript+genshitext, javascript+genshi |
Erlang | erlang |
CoffeeScript | coffee-script, coffeescript |
ANTLR With ActionScript Target | antlr-as, antlr-actionscript |
d-objdump | d-objdump |
CSS+Ruby | css+erb, css+ruby |
MySQL | mysql |
C++ | cpp, c++ |
XML+Smarty | xml+smarty |
Felix | felix, flx |
CMake | cmake |
Mako | mako |
Python | python, py |
JavaScript+Myghty | js+myghty, javascript+myghty |
XML+Mako | xml+mako |
Boo | boo |
ActionScript | as, actionscript |
VB.net | vb.net, vbnet |
SquidConf | squidconf, squid.conf, squid |
D | d |
Logtalk | logtalk |
BBCode | bbcode |
Haml | haml, HAML |
MuPAD | mupad |
XML+Ruby | xml+erb, xml+ruby |
Debian Control file | control |
RHTML | rhtml, html+erb, html+ruby |
JavaScript+Cheetah | js+cheetah, javascript+cheetah, js+spitfire, javascript+spitfire |
Python Traceback | pytb |
cfstatement | cfs |
Ada | ada, ada95ada2005 |
objdump | objdump |
CSS+Mako | css+mako |
Gherkin | Cucumber, cucumber, Gherkin, gherkin |
Ragel in Java Host | ragel-java |
Io | io |
Vala | vala, vapi |
Haskell | haskell, hs |
Lua | lua |
Sass | sass, SASS |
ANTLR With ObjectiveC Target | antlr-objc |
XML | xml |
Groff | groff, nroff, man |
GLSL | glsl |
Genshi Text | genshitext |
Objective-J | objective-j, objectivej, obj-j, objj |
GAS | gas |
Sesión de consola Python | pycon |
MXML | mxml |
XML+Cheetah | xml+cheetah, xml+spitfire |
Go | go |
Ragel in C Host | ragel-c |
aspx-cs | aspx-cs |
Ragel in Ruby Host | ragel-ruby, ragel-rb |
HTML+Genshi | html+genshi, html+kid |
Perl | perl, pl |
INI | ini, cfg |
c-objdump | c-objdump |
Tcsh | tcsh, csh |
RConsole | rconsole, rout |
CSS+Smarty | css+smarty |
ANTLR With C# Target | antlr-csharp, antlr-c# |
Darcs Patch | dpatch |
LLVM | llvm |
Nginx configuration file | nginx |
AppleScript | applescript |
Text only | text |
Literate Haskell | lhs, literate-haskell |
PHP | php, php3, php4, php5 |
MiniD | minid |
Ooc | ooc |
SQL | sql |
NASM | nasm |
Debian Sourcelist | sourceslist, sources.list |
Delphi | delphi, pas, pascal, objectpascal |
aspx-vb | aspx-vb |
HTML+Evoque | html+evoque |
NumPy | numpy |
Modula-2 | modula2, m2 |
HTML+Django/Jinja | html+django, html+jinja |
CSS+PHP | css+php |
VimL | vim |
CSS+Genshi Text | css+genshitext, css+genshi |
Ragel | ragel |
XML+Evoque | xml+evoque |
haXe | hx, haXe |
Redcode | redcode |
Django/Jinja | django, jinja |
Scala | scala |
Archivo de configuración Lighttpd | lighty, lighttpd |
Ragel en D Host | ragel-d |
Ruby irb session | rbcon, irb |
CSS | css |
JavaScript+Smarty | js+smarty, javascript+smarty |
Asymptote | asy, asymptote |
XML+PHP | xml+php |
Fortran | fortran |
Gnuplot | gnuplot |
REBOL | rebol |
ERB | erb |
Befunge | befunge |
Dylan | dylan |
MoinMoin/Trac Wiki markup | trac-wiki, moin |
Matlab | matlab, octave |
C | c |
HTML | html |
Genshi | genshi, kid, xml+genshi, xml+kid |
reStructuredText | rst, rest, restructuredtext |
IRC logs | irc |
Prolog | prolog |
CSS+Django/Jinja | css+django, css+jinja |
Smalltalk | smalltalk, squeak |
YAML | yaml |
HTML+Myghty | html+myghty |
Makefile | make, makefile, mf, bsdmake |
XSLT | xslt |
S | splus, s, r |
sqlite3con | sqlite3 |
OCaml | ocaml |
Gettext Catalog | pot, po |
Ruby | rb, ruby |
HTML+Smarty | html+smarty |
POVRay | pov |
Ragel in CPP Host | ragel-cpp |
Evoque | evoque |
Java Server Page | jsp |
ABAP | abap |
HTML+Mako | html+mako |
Diff | diff, udiff |
Matlab session | matlabsession |
HTML+PHP | html+php |
Python 3.0 Traceback | py3tb |
ANTLR With Java Target | antlr-java |
JavaScript+Ruby | js+erb, javascript+erb, js+ruby, javascript+ruby |
Makefile | basemake |
ANTLR With Python Target | antlr-python |
cpp-objdump | cpp-objdump, c++-objdumb, cxx-objdump |
Python 3 | python3, py3 |
Batchfile | bat |
ANTLR | antlr |
JavaScript+Django/Jinja | js+django, javascript+django, js+jinja, javascript+jinja |
Cython | cython, pyx |
Scheme | scheme, scm |
Erlang erl session | erl |
Clojure | clojure, clj |
Modelica | modelica |
ANTLR With Perl Target | antlr-perl |
Myghty | myghty |
Tcl | tcl |
MOOCode | moocode |
Newspeak | newspeak |
Bash Session | console |
Raw token data | raw |
C# | csharp, c# |
TeX | tex, latex |
Cheetah | cheetah, spitfire |
Objective-C | objective-c, objectivec, obj-c, objc |
JavaScript | js, javascript |
Common Lisp | common-lisp, cl |
Embedded Ragel | ragel-em |
ActionScript 3 | as3, actionscript3 |
ANTLR With CPP Target | antlr-cpp |
JavaScript+PHP | js+php, javascript+php |
Ragel in Objective C Host | ragel-objc |
XML+Django/Jinja | xml+django, xml+jinja |
ANTLR With Ruby Target | antlr-ruby, antlr-rb |
XML+Myghty | xml+myghty |