github.com/qichengzx/mattermost-server@v4.5.1-0.20180604164826-2c75247c97d0+incompatible/tests/test-syntax-highlighting.md (about)

     1  # Code Syntax Highlighting
     2  
     3  Verify the following code blocks render as code blocks and highlight properly. 
     4  
     5  ### Diff
     6  
     7  ``` diff
     8  *** /path/to/original	''timestamp''
     9  --- /path/to/new	''timestamp''
    10  ***************
    11  *** 1 ****
    12  ! This is a line.
    13  --- 1 ---
    14  ! This is a replacement line.
    15  It is important to spell
    16  -removed line
    17  +new line
    18  ```
    19  
    20  ### Makefile
    21  
    22  ``` makefile
    23  CC=gcc
    24  CFLAGS=-I.
    25  
    26  hellomake: hellomake.o hellofunc.o
    27       $(CC) -o hellomake hellomake.o hellofunc.o -I.
    28  ```
    29  
    30  ### JSON
    31  
    32  ``` json
    33  {"employees":[
    34      {"firstName":"John", "lastName":"Doe"},
    35  ]}
    36  ```
    37  
    38  ### Markdown
    39  
    40  ``` markdown
    41  **bold** 
    42  *italics* 
    43  [link](www.example.com)
    44  ```
    45  
    46  ### JavaScript
    47  
    48  ``` javascript
    49  document.write('Hello, world!');
    50  ```
    51  
    52  ### CSS
    53  
    54  ``` css
    55  body {
    56      background-color: red;
    57  }
    58  ```
    59  
    60  ### Objective C
    61  
    62  ``` objectivec
    63  #import <stdio.h>
    64  
    65  int main (void)
    66  {
    67  	printf ("Hello world!\n");
    68  }
    69  ```
    70  
    71  ### Python
    72  
    73  ``` python
    74  print "Hello, world!"
    75  ```
    76  
    77  ### XML
    78  
    79  ``` xml
    80  <employees>
    81      <employee>
    82          <firstName>John</firstName> <lastName>Doe</lastName>
    83      </employee>
    84  </employees>
    85  ```
    86  
    87  ### Perl
    88  
    89  ``` perl
    90  print "Hello, World!\n";
    91  ```
    92  
    93  ### Bash
    94  
    95  ``` bash
    96  echo "Hello World"
    97  ```
    98  
    99  ### PHP
   100  
   101  ``` php
   102   <?php echo '<p>Hello World</p>'; ?> 
   103  ```
   104  
   105  ### CoffeeScript
   106  
   107  ``` coffeescript
   108  console.log(“Hello world!”);
   109  ```
   110  
   111  ### C#
   112  
   113  ``` cs
   114  using System;
   115  class Program
   116  {
   117      public static void Main(string[] args)
   118      {
   119          Console.WriteLine("Hello, world!");
   120      }
   121  }
   122  ```
   123  
   124  ### C++
   125  
   126  ``` cpp
   127  #include <iostream.h>
   128  
   129  main()
   130  {
   131      cout << "Hello World!";
   132      return 0;
   133  }
   134  ```
   135  
   136  ### SQL 
   137  
   138  ``` sql
   139  SELECT column_name,column_name
   140  FROM table_name;
   141  ```
   142  
   143  ### Go
   144  
   145  ``` go
   146  package main
   147  import "fmt"
   148  func main() {
   149      fmt.Println("Hello, 世界")
   150  }
   151  ```
   152  
   153  ### Ruby
   154  
   155  ``` ruby
   156  puts "Hello, world!"
   157  ```
   158  
   159  ### Java
   160  
   161  ``` java
   162  import javax.swing.JFrame;  //Importing class JFrame
   163  import javax.swing.JLabel;  //Importing class JLabel
   164  public class HelloWorld {
   165      public static void main(String[] args) {
   166          JFrame frame = new JFrame();           //Creating frame
   167          frame.setTitle("Hi!");                 //Setting title frame
   168          frame.add(new JLabel("Hello, world!"));//Adding text to frame
   169          frame.pack();                          //Setting size to smallest
   170          frame.setLocationRelativeTo(null);     //Centering frame
   171          frame.setVisible(true);                //Showing frame
   172      }
   173  }
   174  ```
   175  
   176  ### Latex Equation
   177  
   178  ``` latex
   179  \frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x).
   180  ```