This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-14. For the latest, interactive version please visit https://mariadb.com/kb/.

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

LenguajeNombre(s) corto(s) permitido(s)
JavaScript+Makojs+mako, javascript+mako
Brainfuckbrainfuck, bf
HTML+Cheetahhtml+cheetah, html+spitfire
Bashbash, sh, ksh
CSS+Myghtycss+myghty
Coldufsion HTMLcfm
Smartysmarty
ApacheConfapacheconf, aconf, apache
Javajava
JavaScript+Genshi Textjs+genshitext, js+genshi, javascript+genshitext, javascript+genshi
Erlangerlang
CoffeeScriptcoffee-script, coffeescript
ANTLR With ActionScript Targetantlr-as, antlr-actionscript
d-objdumpd-objdump
CSS+Rubycss+erb, css+ruby
MySQLmysql
C++cpp, c++
XML+Smartyxml+smarty
Felixfelix, flx
CMakecmake
Makomako
Pythonpython, py
JavaScript+Myghtyjs+myghty, javascript+myghty
XML+Makoxml+mako
Booboo
ActionScriptas, actionscript
VB.netvb.net, vbnet
SquidConfsquidconf, squid.conf, squid
Dd
Logtalklogtalk
BBCodebbcode
Hamlhaml, HAML
MuPADmupad
XML+Rubyxml+erb, xml+ruby
Debian Control filecontrol
RHTMLrhtml, html+erb, html+ruby
JavaScript+Cheetahjs+cheetah, javascript+cheetah, js+spitfire, javascript+spitfire
Python Tracebackpytb
cfstatementcfs
Adaada, ada95ada2005
objdumpobjdump
CSS+Makocss+mako
GherkinCucumber, cucumber, Gherkin, gherkin
Ragel in Java Hostragel-java
Ioio
Valavala, vapi
Haskellhaskell, hs
Lualua
Sasssass, SASS
ANTLR With ObjectiveC Targetantlr-objc
XMLxml
Groffgroff, nroff, man
GLSLglsl
Genshi Textgenshitext
Objective-Jobjective-j, objectivej, obj-j, objj
GASgas
Sesión de consola Pythonpycon
MXMLmxml
XML+Cheetahxml+cheetah, xml+spitfire
Gogo
Ragel in C Hostragel-c
aspx-csaspx-cs
Ragel in Ruby Hostragel-ruby, ragel-rb
HTML+Genshihtml+genshi, html+kid
Perlperl, pl
INIini, cfg
c-objdumpc-objdump
Tcshtcsh, csh
RConsolerconsole, rout
CSS+Smartycss+smarty
ANTLR With C# Targetantlr-csharp, antlr-c#
Darcs Patchdpatch
LLVMllvm
Nginx configuration filenginx
AppleScriptapplescript
Text onlytext
Literate Haskelllhs, literate-haskell
PHPphp, php3, php4, php5
MiniDminid
Oocooc
SQLsql
NASMnasm
Debian Sourcelistsourceslist, sources.list
Delphidelphi, pas, pascal, objectpascal
aspx-vbaspx-vb
HTML+Evoquehtml+evoque
NumPynumpy
Modula-2modula2, m2
HTML+Django/Jinjahtml+django, html+jinja
CSS+PHPcss+php
VimLvim
CSS+Genshi Textcss+genshitext, css+genshi
Ragelragel
XML+Evoquexml+evoque
haXehx, haXe
Redcoderedcode
Django/Jinjadjango, jinja
Scalascala
Archivo de configuración Lighttpdlighty, lighttpd
Ragel en D Hostragel-d
Ruby irb sessionrbcon, irb
CSScss
JavaScript+Smartyjs+smarty, javascript+smarty
Asymptoteasy, asymptote
XML+PHPxml+php
Fortranfortran
Gnuplotgnuplot
REBOLrebol
ERBerb
Befungebefunge
Dylandylan
MoinMoin/Trac Wiki markuptrac-wiki, moin
Matlabmatlab, octave
Cc
HTMLhtml
Genshigenshi, kid, xml+genshi, xml+kid
reStructuredTextrst, rest, restructuredtext
IRC logsirc
Prologprolog
CSS+Django/Jinjacss+django, css+jinja
Smalltalksmalltalk, squeak
YAMLyaml
HTML+Myghtyhtml+myghty
Makefilemake, makefile, mf, bsdmake
XSLTxslt
Ssplus, s, r
sqlite3consqlite3
OCamlocaml
Gettext Catalogpot, po
Rubyrb, ruby
HTML+Smartyhtml+smarty
POVRaypov
Ragel in CPP Hostragel-cpp
Evoqueevoque
Java Server Pagejsp
ABAPabap
HTML+Makohtml+mako
Diffdiff, udiff
Matlab sessionmatlabsession
HTML+PHPhtml+php
Python 3.0 Tracebackpy3tb
ANTLR With Java Targetantlr-java
JavaScript+Rubyjs+erb, javascript+erb, js+ruby, javascript+ruby
Makefilebasemake
ANTLR With Python Targetantlr-python
cpp-objdumpcpp-objdump, c++-objdumb, cxx-objdump
Python 3python3, py3
Batchfilebat
ANTLRantlr
JavaScript+Django/Jinjajs+django, javascript+django, js+jinja, javascript+jinja
Cythoncython, pyx
Schemescheme, scm
Erlang erl sessionerl
Clojureclojure, clj
Modelicamodelica
ANTLR With Perl Targetantlr-perl
Myghtymyghty
Tcltcl
MOOCodemoocode
Newspeaknewspeak
Bash Sessionconsole
Raw token dataraw
C#csharp, c#
TeXtex, latex
Cheetahcheetah, spitfire
Objective-Cobjective-c, objectivec, obj-c, objc
JavaScriptjs, javascript
Common Lispcommon-lisp, cl
Embedded Ragelragel-em
ActionScript 3as3, actionscript3
ANTLR With CPP Targetantlr-cpp
JavaScript+PHPjs+php, javascript+php
Ragel in Objective C Hostragel-objc
XML+Django/Jinjaxml+django, xml+jinja
ANTLR With Ruby Targetantlr-ruby, antlr-rb
XML+Myghtyxml+myghty
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.