Help:Sandkasten: Difference between revisions

From BlueM
Jump to navigation Jump to search
No edit summary
(→‎Syntax highlighting: add WVP test)
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<HIGHLIGHTSYNTAX language="php3">
__NOTOC__
<?php
==Funktionstests==
/**
===Math===
* WikiMedia Extension for Code Syntax Highlighting with the [ http://www.beautifier.org | Beautifier Syntax Highlighting Engine].
<math>x+y=8^{22}</math>
*
* Parses any content defined within the <nowiki><highlightSyntax></highlightSyntax></nowiki> tag
* with the [ http://www.beautifier.org | Beautifier Syntax Highlighting Engine] and
* returns the HTML output.
* @author Lucas Hrabovsky <lucas@amie.st>
* @copyright © 2006 Amie Inc.
* @package MediaWiki
* @subpackage Extensions
* @filesource
*/
/**
* ----------------------------------------
* Configuration Vars.
* ----------------------------------------
* @string BEAUT_PATH The root path to your Beatuifier installation.
* @string LOCAL_SERVER_ROOT The root path to use when opening files on the local server for highlighting.
* @string OUTPUT_HIGHLIGHT_AS Whether to output the HTML as CSS friendly or not.  enum('CSS','HTML')
*/
$BEAUT_PATH = "/path/to/your/beautifier/installation/";
$LOCAL_SERVER_ROOT = "/pathtoyour/public_html/or/www/directory/";
$OUTPUT_HIGHLIGHT_AS = "HTML";
/**
* Add the syntax highlighting extension to the wgExtensionFunctions array.
*/
$wgExtensionFunctions[] = "syntaxHighlightingExtension";
/**
* Register the syntaxHighlightingExtension with the Wiki Parser and associate
* the highlightSyntax tag with the syntaxHighlightingRenderHtml function.
*/
function syntaxHighlightingExtension(){
        global $wgParser;
        $wgParser->setHook("HIGHLIGHTSYNTAX","syntaxHighlightingRenderHtml");
}
/**
* The callback function for converting the input text to HTML output.
*/
function syntaxHighlightingRenderHtml($input, $argv){
        /**
        * Pass in the globals defined above for use in the function.
        */
        global $BEAUT_PATH, $LOCAL_SERVER_ROOT, $OUTPUT_HIGHLIGHT_AS;
        /**
        * Require the two main files for the beautifier.
        */
        require_once ($BEAUT_PATH."Beautifier/Core.php");


        /**
===Syntax highlighting===
        * If a specific language is requested load the relevant file and create the highlighter
====VB.NET====
        */
<source lang="vbnet">
        $myhfile = null;
' Foo
        if($argv["language"]){
Public Sub Foo(ByValue Bar As Integer)
                require_once ($BEAUT_PATH."HFile/HFile_".$argv["language"].".php");
  Return Bar
End Sub
</source>


                if (FALSE === eval("\$myhfile = new HFile_".$argv["language"]."();") ) {
====Fortran====
                        $output .= "Error:1 Could not instantiate HFile_".$argv["language"]."()<br />";
<source lang="fortran">
                }
! Foo
FUNCTION Foo(INT bar)
  RETURN bar
END FUNCTION
</source>


        }
====BlueM====
<bluem>
*Talsperren (*.TAL)
*==================
*
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*| Bez  |  Anfangs-  |  Maximal  | Ge- |  Sohle  |      HW-Entlastung    |      Krone            |
*|      |  volumen  |  volumen  |wicht|          |  Kante      S-Vol  |  Kante      S-Vol  |
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*|      | [Tsd.cbm]  | [Tsd.cbm]  |  -  |  [mNN]  |  [mNN]  | [Tsd.cbm]  |  [mNN]  | [Tsd.cbm]  |
*|-<-->-|-<-------->-|-<-------->-|-<->-|-<------>-|-<------>-|-<-------->-|-<------>-|-<-------->-|
| T170 |        600 |      3650 |  1  |    114.9 |  118.25 |      2650 |  119.25 |      3650 |
| THRB |        500 |      2800 |  1  |      116 |      121 |      2500 |      122 |      2800 |
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*
</bluem>


        /**
====Wave project file====
        * Otherwise use php as a default
<source lang="wvp">
        */
# Import multiple series from multiple files
        else
#-------------------------------------------
        {
file=..\UVF\42960.0_q_28.uvf
                require_once ($BEAUT_PATH."HFile/HFile_php3.php");
file=..\WEL\DEMONA_PSI.wel
                $myhfile = new HFile_php3();
series=S3  _1AB: S3 outflow
        }
series=S3  _1ZU: S3 inflow
file=..\ZRE\Zufl_gem.zre
file=..\BIN\abfluss_1.bin
series=abfluss_1.bin: title="Discharge", unit="m3/s", interpretation=Instantaneous, color=Red, linewidth=4, linestyle=Dash, showPoints=True
file=myrandom.csv
# custom import settings
isColumnSeparated=True
separator=;
dateformat=dd.MM.yyyy HH:mm:ss
decimalSeparator=,
iLineHeadings=1
iLineUnits=8
iLineData=12
useUnits=True
columnWidth=
dateTimeColumnIndex=0
# series to import
series=myseries1
series=myseries2
</source>


        /**
== CSS ==
        * Sett up the highlight object based on whether
<div class="info_versionen">
        * you want the output as CSS freindly or straight HTML.
Versionen
        */
<pre><nowiki><div class="info_versionen"></nowiki></pre>
        if($OUTPUT_HIGHLIGHT_AS=="CSS"){
</div>
                require_once ($BEAUT_PATH."Output/Output_css.php");
                $outputter = new Output_css();
        }
        else {
                require_once ($BEAUT_PATH."Output/Output_HTML.php");
                $outputter = new Output_Html();
        }


        $highlighter = new Core($myhfile, $outputter);
<div class="achtung">
Achtung
<pre><nowiki><div class="achtung"></nowiki></pre>
</div>


        /**
<div class="comment">
        * The meat and potatoes...
Kommentar
        */
<pre><nowiki><div class="comment"></nowiki></pre>
</div>


        /**
Links:
        * If the serverFile argument is passed in the tag, load the local file into the highlighter parser.
* File types:
        */  
** PDF: http://www.example.com/test.pdf
        if($argv["serverFile"]){
** EXE: http://www.example.com/test.exe
                $output .= "<div style=\"font-weight: bold;\"><nowiki><pre></nowiki>\n";
** ZIP: http://www.example.com/test.zip
                $output .= $highlighter->highlight_text($highlighter->load_file($serverRoot.$argv["serverFile"]));
** PPT: http://www.example.com/test.ppt http://www.example.com/test.pptx http://www.example.com/test.pps
                $output .= "</pre></div>";
** DOC: http://www.example.com/test.doc http://www.example.com/test.doc
                return $output;
** XLS: http://www.example.com/test.xls http://www.example.com/test.xlsx
        /**
* Sites:
        * If its a remote file, open it up and parse the returned contents.
** https://downloads.bluemodel.org
        */
** GitHub: https://github.com
        } else if($argv["remoteFile"]){
** Literature: https://tubiblio.ulb.tu-darmstadt.de/ https://dx.doi.org/
                $openFileName = $argv["remoteFile"];
                $fp = fopen($openFileName, "r");
                if(!$fp){
                        $output = "Error: Syntax Highlighter could not open the file ".$openFileName."<br />";
                } else {
                        $fileContents = fread($fp, 8096);
                        fclose($fp);
                        $output .= "<div style=\"font-weight: bold;\"><h1>Code from <a href=\"".$argv["remoteFile"]."\">".$argv["remoteFile"]."</a></h1><nowiki><pre></nowiki>\n";
                        $output .= $highlighter->highlight_text($fileContents);
                        $output .= "</pre></div>";
                }
                return $output;
        /**
        * Else we just want to highlight the code within the syntaxHighlight tags.
        */
        } else {
                $output .= "<div style=\"font-weight: bold;\"><nowiki><pre></nowiki>\n";
                $output .= $highlighter->highlight_text($input);
                $output .= "</pre></div>";
                return $output;
        }
}
?>
</HIGHLIGHTSYNTAX>

Latest revision as of 07:06, 11 November 2023

Funktionstests

Math

[math]\displaystyle{ x+y=8^{22} }[/math]

Syntax highlighting

VB.NET

' Foo
Public Sub Foo(ByValue Bar As Integer)
   Return Bar
End Sub

Fortran

! Foo
FUNCTION Foo(INT bar)
   RETURN bar
END FUNCTION

BlueM

*Talsperren (*.TAL)
*==================
*
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*| Bez  |  Anfangs-  |  Maximal   | Ge- |  Sohle   |      HW-Entlastung    |      Krone            |
*|      |  volumen   |  volumen   |wicht|          |   Kante       S-Vol   |   Kante       S-Vol   |
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*|      | [Tsd.cbm]  | [Tsd.cbm]  |  -  |   [mNN]  |   [mNN]  | [Tsd.cbm]  |   [mNN]  | [Tsd.cbm]  |
*|-<-->-|-<-------->-|-<-------->-|-<->-|-<------>-|-<------>-|-<-------->-|-<------>-|-<-------->-|
 | T170 |        600 |       3650 |  1  |    114.9 |   118.25 |       2650 |   119.25 |       3650 |
 | THRB |        500 |       2800 |  1  |      116 |      121 |       2500 |      122 |       2800 |
*|------|------------|------------|-----|----------|-----------------------|-----------------------|
*

Wave project file

# Import multiple series from multiple files
#-------------------------------------------
file=..\UVF\42960.0_q_28.uvf
file=..\WEL\DEMONA_PSI.wel
 series=S3  _1AB: S3 outflow
 series=S3  _1ZU: S3 inflow
file=..\ZRE\Zufl_gem.zre
file=..\BIN\abfluss_1.bin
 series=abfluss_1.bin: title="Discharge", unit="m3/s", interpretation=Instantaneous, color=Red, linewidth=4, linestyle=Dash, showPoints=True
file=myrandom.csv
 # custom import settings
 isColumnSeparated=True
 separator=;
 dateformat=dd.MM.yyyy HH:mm:ss
 decimalSeparator=,
 iLineHeadings=1
 iLineUnits=8
 iLineData=12
 useUnits=True
 columnWidth=
 dateTimeColumnIndex=0
 # series to import
 series=myseries1
 series=myseries2

CSS

Versionen

<div class="info_versionen">

Achtung

<div class="achtung">

Kommentar

<div class="comment">

Links: