Including a source code file within the wiki

De Wiki de Calcul Québec
Aller à : Navigation, rechercher
Cette page est une traduction de la page Inclure un fichier source dans le wiki et la traduction est complétée à 100 % et à jour.

Autres langues :anglais 100% • ‎français 100%

As explained on the page Including source code within the wiki, you can include source code within the wiki using the <syntaxhighlight> </syntaxhighlight> tag. If you want to separate the code a bit more from the rest of the text, you can use the {{File}} template. This template takes as argument the file name (name parameter), the language of the file (lang parameter) and the content of the file (contents paramter). The default language for this template is bash.

For example,

{{File
  |name=myfile.sh
  |lang="bash"
  |contents=
#!/bin/bash
echo "this is a bash script"
}}

results in:

File : myfile.sh
#!/bin/bash
echo "this is a bash script"


Displaying line numbers

To display line numbers, you can add the option "|lines=yes". For example,

{{File
  |name=monfichier.sh
  |lang="bash"
  |lines=yes
  |contents=
#!/bin/bash
echo "this is a bash script"
}}

results in:

File : myfile.sh
  1. #!/bin/bash
  2. echo "this is a bash script"


Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Ressources de Calcul Québec
Outils
Partager