Syntax Highlighting: Unterschied zwischen den Versionen

Aus FHEMWiki
K (für das Wiki auch noch interessante Sprachen/Syntax)
KKeine Bearbeitungszusammenfassung
 
Zeile 63: Zeile 63:
* perl
* perl
* php
* php
* Wiki markup
* XML
* XML
* YAML
* YAML


[[Kategorie:FHEM Wiki]]
[[Kategorie:FHEM Wiki]]

Aktuelle Version vom 4. März 2020, 12:00 Uhr

FHEMWiki unterstützt Syntax Highlighting mit dem GeSHi-Plugin, das ab Version 1.21 Bestandteil von Mediawiki ist. Dort findet sich auch eine kurze Benutzungsanleitung. Bitte sicherstellen, dass die Formatierung wie gewünscht funktioniert (Seitenvorschau verwenden)!

Ein Anwendungsbeispiel für die Sprache Perl ist in der folgenden Tabelle dargestellt:

Eingabe Formatierte Ausgabe
<syntaxhighlight lang="perl">
 #!/usr/bin/perl
 use strict;
 use warnings;
 
 use Path::Class;
 use autodie; # die if problem reading or writing a file
 
 my $dir = dir("/tmp"); # /tmp
 
 my $file = $dir->file("file.txt"); # /tmp/file.txt
 
 # Get a file_handle (IO::File object) you can write to
 my $file_handle = $file->openw();
 
 my @list = ('a', 'list', 'of', 'lines');
 
 foreach my $line ( @list ) {
     # Add the line to the file
     $file_handle->print($line . "\n");
 }
 </syntaxhighlight>
#!/usr/bin/perl
use strict;
use warnings;

use Path::Class;
use autodie; # die if problem reading or writing a file

my $dir = dir("/tmp"); # /tmp

my $file = $dir->file("file.txt"); # /tmp/file.txt

# Get a file_handle (IO::File object) you can write to
my $file_handle = $file->openw();

my @list = ('a', 'list', 'of', 'lines');

foreach my $line ( @list ) {
    # Add the line to the file
    $file_handle->print($line . "\n");
}

Aus der umfangreichen Liste der unterstützten Sprachen dürften zumindest die folgenden für FHEM relevant sein:

  • bash
  • gnuplot
  • HTML
  • java
  • javascript
  • JSON
  • perl
  • php
  • XML
  • YAML