diff --git a/autotests/folding/example.rmd.fold b/autotests/folding/example.rmd.fold index b1fa2ff..da41517 100644 --- a/autotests/folding/example.rmd.fold +++ b/autotests/folding/example.rmd.fold @@ -1,68 +1,68 @@ --- -title: "test" -author: "me" -date: "07.10.2014" +title: "test" +author: "me" +date: "07.10.2014" output: html_document --- This is a simple test document. It shows syntax highlighting switches between YAML (above), R blocks ```{r, echo=FALSE} for (i in 1:10) { if(i>=10) print(i) } # two blank lines below sessionInfo() ``` LaTeX equations, $$ h_{i}(t \mid q,C) = h_{0}(t) e^{\beta_{1}quality_{i} + \beta_{2}C_{iq}} $$ and Markdown. A [link](http://example.com) in Markdown. Inline `r y <- 5 + x - sin(3)` R code. Inline `y <- 5 + x - sin(3)` code. Heading ======= Sub-heading ----------- A list of editors: * kate * vim * emacs *italic*, **bold**, `monospace` code block more code normal text normal text normal text 1. item * This is a list item with multiple lines. ```{r pressure, echo=FALSE} plot(pressure) ``` > This is a blockquote `r cos(33) ` This is a new paragraph, which is part of this $$ \text{item} $$. indented code block Other paragraph. * subitem * subitem $$ A = B + C $$ diff --git a/autotests/folding/test.markdown.fold b/autotests/folding/test.markdown.fold index 82c3baa..1a12442 100644 --- a/autotests/folding/test.markdown.fold +++ b/autotests/folding/test.markdown.fold @@ -1,582 +1,600 @@ --- Title: A Sample Markdown Document Author: Fletcher T. Penney Date: February 9, 2011 Comment: This is a comment intended to demonstrate metadata that spans multiple lines. --- # H1 ## H2 ### H3 Multi-line paragraph bla bla bla bla bla bla. Intentional line break via two spaces at line. Formats: _italic_, **bold**, `monospace`, ~~strikeout~~ Bullet list: * item1 * item2 Numbered list: 1. item 1 2. item 2 Task list: - [x] Finish my changes - [ ] Push my commits - [ ] Open a pull request A link as normal text: http://example.com [link](http://kde.org) Auto-link: Mail: This is [an example](http://example.com/ "Title") inline link. See my [About](/about/) page for details. This is [an example] [id] reference-style link. [id]: http://example.com/ "Optional Title Here" [foo]: http://example.com/ 'Optional Title Here' [bar]: http://example.com/ (Optional Title Here) [id2]: "Optional Title Here" ![Alt text](/path/to/img.jpg) ![Alt text](/path/to/img.jpg "Optional title") [![Alt text](https://url/to/img.svg)](https://link.com/example/) code 1 code 2 normal text > block quote _italic_ > more block quote normal text Title: some text normal text # Lists 1. item * This is a list item with multiple lines. ``` code ``` > This is a blockquote This is a new paragraph, which is part of the item in the previous list. indented code block Other paragraph. * subitem * subitem with multiple lines. New paragraph of the previous subitem. code block ----------------------- Other paragraph of the subitem. 30. numlist item 31. numlist item New paragraph of the previous item. > Blockquote code block Other paragraph. # Inline HTML © bold code > a b >
  • c
  • d
  • > e
    > normal text *italic* # Code `simple code` ``simple ` code`` ```simple `` ` code ``` ````simple`code```` normal text normal text normal text normal text code blocks are only allowed after an empty line. * list list normal text 1. num-list num-list normal text > quote quote code block normal code normal code # Fenced code blocks (bug 356974) ## Bash ```bash #!/usr/bin/env bash for f in *; do echo "$f" done ``` ## C++ ```cpp #include class Q : public QObject { Q_OBJECT public: Q(); } Q::Q() :QObject(NULL) { } ``` ## C ```c #include #include "stdint.h" #define SOME_VAR 1 static uint64_t intWithSuffix = 42ull + ~1233L; static int octNum = 07232; ``` ## C# ## ```csharp var arr = new[] { 0, 1, 2, 3, 4 }; var anon = new { Country = "Germany", Inhabitants = 80000000 }; ``` ## CMake ```cmake cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project (hello_world) set(QT_MIN_VERSION "5.6.0") ``` ## CSS ```css h1.main::hover { font-size: 100; color: green; } ``` ## Email ```email From: Konqi Dragon To: All Subject: highlights ``` ## Go ```go package main import "fmt" func main() { fmt.Println("Hola, mundo.") } ``` ## Haskell ```haskell module Main (main) where main :: IO () main = putStrLn "Hello, World!" ``` ## HTML ```html

    Hello world!

    ``` ## Java ```java package fibsandlies; import java.util.HashMap; /** * This is an example of a Javadoc comment; Javadoc can compile documentation * from this text. Javadoc comments must immediately precede the class, method, or field being documented. */ public class FibCalculator extends Fibonacci implements Calculator { private static Map memoized = new HashMap(); public static void main(String[] args) { memoized.put(1, 1); memoized.put(2, 1); System.out.println(fibonacci(12)); } } ``` ## JavaScript ```js function factorial(n) { if (n === 0) { return 1; // 0! = 1 } return n * factorial(n - 1); } ``` ## JavaScript React (JSX) ```jsx /> function Story(props) { const SpecificStory = components[props.storyType]; return story={ props.story } attr2="&ref;" attr3="Hello\n" />; } ``` ## JSON ```json [{ "hello": "world", "count": 1, "bool": true }] ``` ## Matlab ```matlab % Numbers _____________________________________________ 5, 5.5, .1, 0.1, 0.4e5, 1.2e-5, 5i, 5.3i, 6j, .345+3i 5', 5.5', .1', 0.1', 0.4e5', 1.2e-5', 5i', 5.3i', 6j', .345+3i' ``` ## Markdown ```markdown **bold** `code` > quote ``` ## Mustache/Handlebars ```handlebars {{#movie}} >

    {{title}}

    {{title}}
    > > Rating - {{ratings.critics_rating}} > {{/movie}} ``` ## Perl ```perl my $var = shift; $var =~ s/bla/foo/igs; $var =~ s!bla!foo!igs; $var =~ s#bla#foo#igs; ``` ## PHP ```php namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; class IndexController extends AbstractActionController { } ``` ## Python ```python def addXToY(x, y): total = x + y print total ``` ## QML ```qml Text { id: hello width: 100 text: "Hello world!" } ``` ## R ```r # Declare function “f” with parameters “x”, “y“ # that returns a linear combination of x and y. f <- function(x, y) { z <- 3 * x + 4 * y return(z) } ``` +## Raku + +```raku +grammar Parser { + rule TOP { I } + token love { '♥' | love } + token lang { < Raku Perl Rust Go Python Ruby > } +} + +say Parser.parse: 'I ♥ Raku'; + +say 1 #`««« blah TODO blah +here? »»» 2 ; +say 1 #` ( blah TODO blah +2 ; +rx- regex - +``` + ## Ruby ```ruby require 'Config' - def CGI::escape(string) - string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do + def CGI::escape(string) + string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do '%' + $1.unpack('H2' * $1.size).join('%').upcase - end.tr(' ', '+') - end + end.tr(' ', '+') + end ``` ## Rust ```rust -fn main() { +fn main() { println!("Hello world!"); -} +} ``` ## MySQL ```mysql -- comment CREATE TABLE stuff COLUMNS(col1 INT, col2 Varchar); SELECT * FROM stuff WHERE id = 'string'; select * from stuff where id < 0.42; Select col1, col2 From stuff Where stuff.col1 IS NOT NuLL; ``` ## TypeScript ```ts class Student { fullName: string; constructor(public firstName: string, public middleInitial: string, public lastName: string) { this.fullName = firstName + " " + middleInitial + " " + lastName; } } ``` ## XML ```xml - attribute="3"> - /> -> + attribute="3"> + /> +> ``` ## reStructuredText ```rst Section Header ============== .. image:: /path/to/image.jpg - A bullet list item ``` ## Doxygen ```doxygen a normal member taking two arguments and returning an integer value. @param a an integer argument. @param s a constant character pointer. @see Javadoc_Test() @see publicVar() @return The test results ``` ## No language specified ``` No language is specified, but it should be still rendered as code block. ``` # Fenced code blocks with more than 3 backticks or tildes ~~~ Fenced code block with 3 tildes. ~~~ ````````` Some implementations of Markdown/MultiMarkdown support more than 3 backticks or tildes. ``` The block ends with the same amount of backticks. ````````` ~~~~~~~~~~~~ Fenced code block with more tildes. ~~~~~~~~~~~~ ## With languages ```````html

    Hello world!

    ``` ``````` ~~~bash for f in *; do echo "$f" done ~~~ ~~~~~~~~~python def addXToY(x, y): total = x + y print total ~~~ # <= doesn't end here ~~~~~~~~~ # Italic and bold text **b** *i* __b__ _i_ ***ib*** ___ib___ **_ib_** __*ib*__ * _italic_ **bold** ***ib*** ~~strikeout~~ > _italic_ **bold** ***ib*** ~~strikeout~~ ## Bold **bold*___text** normal __bold_***text__ normal ## Italic *italic _ text* normal _italic * text_ normal ## Italic-Bold ***italic-bold ** italic-bold*** normal ***bold-italic text **bold-italic text*** normal ***bold*italic*** normal **_bold-italic text_** normal _ normal text_ * normal text * *italic text*normal text* *italic text *italic text* **bold text**normal text** **bold text **bold text** aaa**bold text**aaaaa aaa__normal text__aaaaa пристаням_стремятся_ \*normal text* _normal text\_ **italic text\** ***only bold\*** **bold\** bold** diff --git a/autotests/html/test.markdown.html b/autotests/html/test.markdown.html index eccec2b..8a74f3f 100644 --- a/autotests/html/test.markdown.html +++ b/autotests/html/test.markdown.html @@ -1,589 +1,607 @@ test.markdown
     ---
     Title:    A Sample Markdown Document
     Author:   Fletcher T. Penney
     Date:     February 9, 2011
     Comment:  This is a comment intended to demonstrate 
               metadata that spans multiple lines.
     ---
     
     # H1
     
     ## H2
     
     ### H3
     
     Multi-line paragraph bla bla bla
     bla bla bla.
     
     Intentional line break  
     via two spaces at line.
     
     Formats: _italic_, **bold**, `monospace`, ~~strikeout~~
     
     Bullet list:
     
     * item1
     * item2
     
     Numbered list:
     
     1. item 1
     2. item 2
     
     Task list:
     
     - [x] Finish my changes
     - [ ] Push my commits
     - [ ] Open a pull request
     
     A link as normal text: http://example.com
     
     [link](http://kde.org)
     
     Auto-link: <http://kate-editor.org>
     Mail: <mailto:mark@kde.org>
     
     This is [an example](http://example.com/ "Title") inline link.
     
     See my [About](/about/) page for details.
     
     This is [an example] [id] reference-style link.
     
     [id]: http://example.com/  "Optional Title Here"
     [foo]: http://example.com/ 'Optional Title Here'
     [bar]: http://example.com/ (Optional Title Here)
     [id2]: <http://example.com/>  "Optional Title Here"
     
     ![Alt text](/path/to/img.jpg)
     
     ![Alt text](/path/to/img.jpg "Optional title")
     
     [![Alt text](https://url/to/img.svg)](https://link.com/example/)
     
         code 1
         code 2
     
     normal text
     
     > block quote _italic_
     > more block quote
     
     normal text
     
     Title: some text
     
     normal text
     
     # Lists
     
     1. item
        * This is a list item
          with multiple lines.
          ```
          code
          ```
     
          > This is a
          blockquote
     
          This is a new paragraph, which
          is part of the item in the
          previous list.
     
              indented code block
     
            Other paragraph.
     
          * subitem
            * subitem
              with multiple
                 lines.
     
              New paragraph of
              the previous subitem.
     
                  code block
     
               -----------------------
     
                 Other paragraph of
                 the subitem.
     
               30. numlist item
               31. numlist item
     
                      New paragraph of
                      the previous item.
     
                      > Blockquote
     
                       code block
       
                   Other paragraph.
     
     # Inline HTML
     
     &copy;
     <strong>bold</strong>
     <code>code</code>
     
     <table>
         <tr>
             <th>a</th>
             <th>b</th>
         </tr>
         <tr>
             <th><ul>
                 <li>c</li>
                 <li>d</li>
             </ul></th>
             <th>e</th>
         </tr>
     </table>
     
     normal text *italic*
     
     # Code
     
     `simple code`
     
     ``simple ` code``
     
     ```simple `` ` code ```
     
     ````simple`code````
     
     normal text
         normal text
         normal text
             normal text
     
         code blocks are only allowed
         after an empty line.
     
     * list
         list
         
         normal text
         
     1. num-list
         num-list
     
         normal text
     
     > quote
         quote
         
         code block
     
     normal
     <!-- comment -->
         <!-- code, not comment -->
         code
     
     normal
     
       <!-- coment -->
         code
     
     # Fenced code blocks (bug 356974)
     
     ## Bash
     
     ```bash
     #!/usr/bin/env bash
     
     for f in *; do
         echo "$f"
     done
     ```
     
     ## C++
     
     ```cpp
     #include <QtCore/QObject>
     
     class Q : public QObject {
     Q_OBJECT
     public:
         Q();
     }
     
     Q::Q() :QObject(NULL) {
     }
     ```
     
     ## C
     
     ```c
     #include <stdio.h>
     #include "stdint.h"
     #define SOME_VAR 1
     
     static uint64_t intWithSuffix = 42ull + ~1233L;
     static int octNum = 07232;
     ```
     
     ## C#  ##
     
     ```csharp
     var arr = new[] { 0, 1, 2, 3, 4 };
     var anon = new { Country = "Germany", Inhabitants = 80000000 };
     ```
     
     ## CMake
     
     ```cmake
     cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
     
     project (hello_world)
     
     set(QT_MIN_VERSION "5.6.0")
     ```
     
     ## CSS
     
     ```css
     h1.main::hover {
         font-size: 100;
         color: green;
     }
     ```
     
     ## Email
     
     ```email
     From: Konqi Dragon <konqi@kde.org>
     To: All <all@kde.og>
     Subject: highlights
     ```
     
     ## Go
     
     ```go
     package main
     
     import "fmt"
     
     func main() {
       fmt.Println("Hola, mundo.")
     }
     ```
     
     ## Haskell
     
     ```haskell
     module Main (main) where
     
     main :: IO ()
     main = putStrLn "Hello, World!"
     ```
     
     ## HTML
     
     ```html
     <html>
       <body>
         <p class="main">Hello world!</p>
       </body>
     </html>
     ```
     
     ## Java
     
     ```java
     package fibsandlies;
     import java.util.HashMap;
     
     /**
      * This is an example of a Javadoc comment; Javadoc can compile documentation
      * from this text. Javadoc comments must immediately precede the class, method, or field being documented.
      */
     public class FibCalculator extends Fibonacci implements Calculator {
     
         private static Map<Integer, Integer> memoized = new HashMap<Integer, Integer>();
         public static void main(String[] args) {
             memoized.put(1, 1);
             memoized.put(2, 1);
             System.out.println(fibonacci(12));
         }
     }
     ```
     
     ## JavaScript
     
     ```js
     function factorial(n) {
         if (n === 0) {
             return 1;  // 0! = 1
         }
         return n * factorial(n - 1);
     }
     ```
     
     ## JavaScript React (JSX)
     
     ```jsx
     <hello />
     function Story(props) {
       const SpecificStory = components[props.storyType];
       return <SpecificStory story={ props.story } attr2="&ref;" attr3="Hello\n" />;
     }
     ```
     
     ## JSON
     
     ```json
     [{
         "hello": "world",
         "count": 1,
         "bool": true
     }]
     ```
     
     ## Matlab
     
     ```matlab
     % Numbers _____________________________________________
     5, 5.5, .1, 0.1, 0.4e5, 1.2e-5, 5i, 5.3i, 6j, .345+3i
     5', 5.5', .1', 0.1', 0.4e5', 1.2e-5', 5i', 5.3i', 6j', .345+3i'
     ```
     
     ## Markdown
     
     ```markdown
     **bold** `code`
     > quote
     
     ```
     
     ## Mustache/Handlebars
     
     ```handlebars
     {{#movie}}
         <div>
             <h1>{{title}}</h1>
             <img src="{{poster}}" alt="{{title}}"/>
         </div>
         <div>
             Rating - {{ratings.critics_rating}}
         </div>
     {{/movie}}
     ```
     
     ## Perl
     
     ```perl
     my $var = shift;
     
     $var =~ s/bla/foo/igs;
     $var =~ s!bla!foo!igs;
     $var =~ s#bla#foo#igs;
     ```
     
     ## PHP
     
     ```php
     namespace Application\Controller;
     
     use Zend\Mvc\Controller\AbstractActionController;
     
     class IndexController extends AbstractActionController
     {
     }
     ```
     
     ## Python
     
     ```python
     def addXToY(x, y):
         total = x + y
         print total
     ```
     
     ## QML
     
     ```qml
     Text {
         id: hello
         width: 100
         text: "Hello world!"
     }
     ```
     
     ## R
     
     ```r
     # Declare function “f” with parameters “x”, “y“
     # that returns a linear combination of x and y.
     f <- function(x, y) {
       z <- 3 * x + 4 * y
       return(z)
     }
     ```
     
    +## Raku
    +
    +```raku
    +grammar Parser {
    +    rule  TOP  { I <love> <lang> }
    +    token love { '' | love }
    +    token lang { < Raku Perl Rust Go Python Ruby > }
    +}
    +
    +say Parser.parse: 'I ♥ Raku';
    +
    +say 1 #`««« blah TODO blah
    +here? »»» 2 ;
    +say 1 #` ( blah TODO blah
    +2 ;
    +rx- regex -
    +```
    +
     ## Ruby
     
     ```ruby
     require 'Config'
       def CGI::escape(string)
         string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
           '%' + $1.unpack('H2' * $1.size).join('%').upcase
         end.tr(' ', '+')
       end
     ```
     
     ## Rust
     
     ```rust
     fn main() {
         println!("Hello world!");
     }
     ```
     
     ## MySQL
     
     ```mysql
     -- comment
     CREATE TABLE stuff COLUMNS(col1 INT, col2 Varchar);
     SELECT * FROM stuff WHERE id = 'string';
     select * from stuff where id < 0.42;
     Select col1, col2 From stuff Where stuff.col1 IS NOT NuLL;
     ```
     
     ## TypeScript
     
     ```ts
     class Student {
         fullName: string;
         constructor(public firstName: string, public middleInitial: string, public lastName: string) {
             this.fullName = firstName + " " + middleInitial + " " + lastName;
         }
     }
     ```
     
     ## XML
     
     ```xml
     <tag attribute="3">
       <nested/>
     </tag>
     ```
     
     ## reStructuredText
     
     ```rst
     Section Header
     ==============
     
     .. image:: /path/to/image.jpg
     
     - A bullet list item
     ```
     
     ## Doxygen
     
     ```doxygen
     a normal member taking two arguments and returning an integer value.
     @param a an integer argument.
     @param s a constant character pointer.
     @see Javadoc_Test()
     @see publicVar()
     @return The test results
     ```
     
     ## No language specified
     
     ```
     No language is specified, but it should be still rendered as code block.
     ```
     
     # Fenced code blocks with more than 3 backticks or tildes
     
     ~~~
     Fenced code block with 3 tildes.
     ~~~
     
     `````````
     Some implementations of Markdown/MultiMarkdown support more than 3 backticks or tildes.
     ```
     The block ends with the same amount of backticks.
     `````````
     
     ~~~~~~~~~~~~
     Fenced code block with more tildes.
     ~~~~~~~~~~~~
     
     ## With languages
     
     ```````html
     <html>
       <body>
         <p class="main">Hello world!</p>
       </body>
     </html>
     ``` <!-- <= doesn't end here -->
     ```````
     
     ~~~bash
     for f in *; do
         echo "$f"
     done
     ~~~
     
     ~~~~~~~~~python
     def addXToY(x, y):
         total = x + y
         print total
     ~~~ # <= doesn't end here
     ~~~~~~~~~
     
     # Italic and bold text
     
     **b** *i* __b__ _i_
     ***ib*** ___ib___
     **_ib_** __*ib*__
     
     * _italic_ **bold** ***ib*** ~~strikeout~~
     
     > _italic_ **bold** ***ib*** ~~strikeout~~
     
     ## Bold
     **bold*___text** normal
     __bold_***text__ normal
     
     ## Italic
     *italic _ text* normal
     _italic * text_ normal
     
     ## Italic-Bold
     ***italic-bold ** italic-bold*** normal
     ***bold-italic text **bold-italic text*** normal
     ***bold*italic*** normal
     **_bold-italic text_** normal
     
     <!-- A non-space character is required after or before * or _ -->
     _ normal text_ * normal text *
     *italic text*normal text*
     *italic text *italic text*
     **bold text**normal text**
     **bold text **bold text**
     
     <!-- A delimiter is required after or before _ -->
     aaa**bold text**aaaaa
     aaa__normal text__aaaaa
     пристаням_стремятся_
     
     <!-- Escapes within bold or italic text -->
     \*normal text*
     _normal text\_
     **italic text\**
     ***only bold\***
     **bold\** bold**
     
    diff --git a/autotests/input/test.markdown b/autotests/input/test.markdown index 0ad9c2e..df196c3 100644 --- a/autotests/input/test.markdown +++ b/autotests/input/test.markdown @@ -1,582 +1,600 @@ --- Title: A Sample Markdown Document Author: Fletcher T. Penney Date: February 9, 2011 Comment: This is a comment intended to demonstrate metadata that spans multiple lines. --- # H1 ## H2 ### H3 Multi-line paragraph bla bla bla bla bla bla. Intentional line break via two spaces at line. Formats: _italic_, **bold**, `monospace`, ~~strikeout~~ Bullet list: * item1 * item2 Numbered list: 1. item 1 2. item 2 Task list: - [x] Finish my changes - [ ] Push my commits - [ ] Open a pull request A link as normal text: http://example.com [link](http://kde.org) Auto-link: Mail: This is [an example](http://example.com/ "Title") inline link. See my [About](/about/) page for details. This is [an example] [id] reference-style link. [id]: http://example.com/ "Optional Title Here" [foo]: http://example.com/ 'Optional Title Here' [bar]: http://example.com/ (Optional Title Here) [id2]: "Optional Title Here" ![Alt text](/path/to/img.jpg) ![Alt text](/path/to/img.jpg "Optional title") [![Alt text](https://url/to/img.svg)](https://link.com/example/) code 1 code 2 normal text > block quote _italic_ > more block quote normal text Title: some text normal text # Lists 1. item * This is a list item with multiple lines. ``` code ``` > This is a blockquote This is a new paragraph, which is part of the item in the previous list. indented code block Other paragraph. * subitem * subitem with multiple lines. New paragraph of the previous subitem. code block ----------------------- Other paragraph of the subitem. 30. numlist item 31. numlist item New paragraph of the previous item. > Blockquote code block Other paragraph. # Inline HTML © bold code
    a b
    • c
    • d
    e
    normal text *italic* # Code `simple code` ``simple ` code`` ```simple `` ` code ``` ````simple`code```` normal text normal text normal text normal text code blocks are only allowed after an empty line. * list list normal text 1. num-list num-list normal text > quote quote code block normal code normal code # Fenced code blocks (bug 356974) ## Bash ```bash #!/usr/bin/env bash for f in *; do echo "$f" done ``` ## C++ ```cpp #include class Q : public QObject { Q_OBJECT public: Q(); } Q::Q() :QObject(NULL) { } ``` ## C ```c #include #include "stdint.h" #define SOME_VAR 1 static uint64_t intWithSuffix = 42ull + ~1233L; static int octNum = 07232; ``` ## C# ## ```csharp var arr = new[] { 0, 1, 2, 3, 4 }; var anon = new { Country = "Germany", Inhabitants = 80000000 }; ``` ## CMake ```cmake cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project (hello_world) set(QT_MIN_VERSION "5.6.0") ``` ## CSS ```css h1.main::hover { font-size: 100; color: green; } ``` ## Email ```email From: Konqi Dragon To: All Subject: highlights ``` ## Go ```go package main import "fmt" func main() { fmt.Println("Hola, mundo.") } ``` ## Haskell ```haskell module Main (main) where main :: IO () main = putStrLn "Hello, World!" ``` ## HTML ```html

    Hello world!

    ``` ## Java ```java package fibsandlies; import java.util.HashMap; /** * This is an example of a Javadoc comment; Javadoc can compile documentation * from this text. Javadoc comments must immediately precede the class, method, or field being documented. */ public class FibCalculator extends Fibonacci implements Calculator { private static Map memoized = new HashMap(); public static void main(String[] args) { memoized.put(1, 1); memoized.put(2, 1); System.out.println(fibonacci(12)); } } ``` ## JavaScript ```js function factorial(n) { if (n === 0) { return 1; // 0! = 1 } return n * factorial(n - 1); } ``` ## JavaScript React (JSX) ```jsx function Story(props) { const SpecificStory = components[props.storyType]; return ; } ``` ## JSON ```json [{ "hello": "world", "count": 1, "bool": true }] ``` ## Matlab ```matlab % Numbers _____________________________________________ 5, 5.5, .1, 0.1, 0.4e5, 1.2e-5, 5i, 5.3i, 6j, .345+3i 5', 5.5', .1', 0.1', 0.4e5', 1.2e-5', 5i', 5.3i', 6j', .345+3i' ``` ## Markdown ```markdown **bold** `code` > quote ``` ## Mustache/Handlebars ```handlebars {{#movie}}

    {{title}}

    {{title}}
    Rating - {{ratings.critics_rating}}
    {{/movie}} ``` ## Perl ```perl my $var = shift; $var =~ s/bla/foo/igs; $var =~ s!bla!foo!igs; $var =~ s#bla#foo#igs; ``` ## PHP ```php namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; class IndexController extends AbstractActionController { } ``` ## Python ```python def addXToY(x, y): total = x + y print total ``` ## QML ```qml Text { id: hello width: 100 text: "Hello world!" } ``` ## R ```r # Declare function “f” with parameters “x”, “y“ # that returns a linear combination of x and y. f <- function(x, y) { z <- 3 * x + 4 * y return(z) } ``` +## Raku + +```raku +grammar Parser { + rule TOP { I } + token love { '♥' | love } + token lang { < Raku Perl Rust Go Python Ruby > } +} + +say Parser.parse: 'I ♥ Raku'; + +say 1 #`««« blah TODO blah +here? »»» 2 ; +say 1 #` ( blah TODO blah +2 ; +rx- regex - +``` + ## Ruby ```ruby require 'Config' def CGI::escape(string) string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do '%' + $1.unpack('H2' * $1.size).join('%').upcase end.tr(' ', '+') end ``` ## Rust ```rust fn main() { println!("Hello world!"); } ``` ## MySQL ```mysql -- comment CREATE TABLE stuff COLUMNS(col1 INT, col2 Varchar); SELECT * FROM stuff WHERE id = 'string'; select * from stuff where id < 0.42; Select col1, col2 From stuff Where stuff.col1 IS NOT NuLL; ``` ## TypeScript ```ts class Student { fullName: string; constructor(public firstName: string, public middleInitial: string, public lastName: string) { this.fullName = firstName + " " + middleInitial + " " + lastName; } } ``` ## XML ```xml ``` ## reStructuredText ```rst Section Header ============== .. image:: /path/to/image.jpg - A bullet list item ``` ## Doxygen ```doxygen a normal member taking two arguments and returning an integer value. @param a an integer argument. @param s a constant character pointer. @see Javadoc_Test() @see publicVar() @return The test results ``` ## No language specified ``` No language is specified, but it should be still rendered as code block. ``` # Fenced code blocks with more than 3 backticks or tildes ~~~ Fenced code block with 3 tildes. ~~~ ````````` Some implementations of Markdown/MultiMarkdown support more than 3 backticks or tildes. ``` The block ends with the same amount of backticks. ````````` ~~~~~~~~~~~~ Fenced code block with more tildes. ~~~~~~~~~~~~ ## With languages ```````html

    Hello world!

    ``` ``````` ~~~bash for f in *; do echo "$f" done ~~~ ~~~~~~~~~python def addXToY(x, y): total = x + y print total ~~~ # <= doesn't end here ~~~~~~~~~ # Italic and bold text **b** *i* __b__ _i_ ***ib*** ___ib___ **_ib_** __*ib*__ * _italic_ **bold** ***ib*** ~~strikeout~~ > _italic_ **bold** ***ib*** ~~strikeout~~ ## Bold **bold*___text** normal __bold_***text__ normal ## Italic *italic _ text* normal _italic * text_ normal ## Italic-Bold ***italic-bold ** italic-bold*** normal ***bold-italic text **bold-italic text*** normal ***bold*italic*** normal **_bold-italic text_** normal _ normal text_ * normal text * *italic text*normal text* *italic text *italic text* **bold text**normal text** **bold text **bold text** aaa**bold text**aaaaa aaa__normal text__aaaaa пристаням_стремятся_ \*normal text* _normal text\_ **italic text\** ***only bold\*** **bold\** bold** diff --git a/autotests/reference/test.markdown.ref b/autotests/reference/test.markdown.ref index d14e419..268c0f4 100644 --- a/autotests/reference/test.markdown.ref +++ b/autotests/reference/test.markdown.ref @@ -1,582 +1,600 @@ ---
    Title: A Sample Markdown Document
    Author: Fletcher T. Penney
    Date: February 9, 2011
    Comment: This is a comment intended to demonstrate
    metadata that spans multiple lines.
    ---

    # H1


    ## H2


    ### H3


    Multi-line paragraph bla bla bla
    bla bla bla.

    Intentional line break
    via two spaces at line.

    Formats: _italic_, **bold**, `monospace`, ~~strikeout~~

    Bullet list:

    * item1
    * item2

    Numbered list:

    1. item 1
    2. item 2

    Task list:

    - [x] Finish my changes
    - [ ] Push my commits
    - [ ] Open a pull request

    A link as normal text: http://example.com

    [link](http://kde.org)

    Auto-link: <http://kate-editor.org>
    Mail: mark@kde.org>

    This is [an example](http://example.com/ "Title") inline link.

    See my [About](/about/) page for details.

    This is [an example] [id] reference-style link.

    [id]: http://example.com/ "Optional Title Here"
    [foo]: http://example.com/ 'Optional Title Here'
    [bar]: http://example.com/ (Optional Title Here)
    [id2]: <http://example.com/> "Optional Title Here"

    ![Alt text](/path/to/img.jpg)

    ![Alt text](/path/to/img.jpg "Optional title")

    [![Alt text](https://url/to/img.svg)](https://link.com/example/)

    code 1
    code 2

    normal text

    >
    block quote _italic_
    >
    more block quote

    normal text

    Title: some text

    normal text

    # Lists


    1. item
    * This is a list item
    with multiple lines.
    ```
    code
    ```

    >
    This is a
    blockquote

    This is a new paragraph, which
    is part of the item in the
    previous list.

    indented code block

    Other paragraph.

    * subitem
    * subitem
    with multiple
    lines.

    New paragraph of
    the previous subitem.

    code block

    -----------------------

    Other paragraph of
    the subitem.

    30. numlist item
    31. numlist item

    New paragraph of
    the previous item.

    >
    Blockquote

    code block

    Other paragraph.

    # Inline HTML


    ©
    bold
    code










    a b

    • c

    • d

    e


    normal text *italic*

    # Code


    `simple code`

    ``simple ` code``

    ```simple `` ` code ```

    ````simple`code````

    normal text
    normal text
    normal text
    normal text

    code blocks are only allowed
    after an empty line.

    * list
    list

    normal text

    1. num-list
    num-list

    normal text

    >
    quote
    quote

    code block

    normal


    code

    normal


    code

    # Fenced code blocks (bug 356974)


    ## Bash


    ```bash
    #!/usr/bin/env bash

    for f *; do
    echo "$f"
    done
    ```

    ## C++


    ```cpp
    #include

    class Q : public QObject {
    Q_OBJECT
    public:
    Q();
    }

    Q::Q() :QObject(NULL) {
    }
    ```

    ## C


    ```c
    #include
    #include "stdint.h"
    #define SOME_VAR 1

    static uint64_t intWithSuffix = 42ull + ~1233L;
    static int octNum = 07232;
    ```

    ## C# ##


    ```csharp
    var arr = new[] { 0, 1, 2, 3, 4 };
    var anon = new { Country = "Germany", Inhabitants = 80000000 };
    ```

    ## CMake


    ```cmake
    cmake_minimum_required(VERSION 3.10 FATAL_ERROR)

    project (hello_world)

    set(QT_MIN_VERSION "5.6.0")
    ```

    ## CSS


    ```css
    h1.main::hover {
    font-size: 100;
    color: green;
    }
    ```

    ## Email


    ```email
    From: Konqi Dragon

    To: All

    Subject: highlights
    ```

    ## Go


    ```go
    package main

    import "fmt"

    func main() {
    fmt.Println("Hola, mundo.")
    }
    ```

    ## Haskell


    ```haskell
    module Main (main) where

    main :: IO ()
    main = putStrLn "Hello, World!"
    ```

    ## HTML


    ```html


    class="main">Hello world!




    ```

    ## Java


    ```java
    package fibsandlies;
    import java.util.HashMap;

    /**
    * This is an example of a Javadoc comment; Javadoc can compile documentation
    * from this text. Javadoc comments must immediately precede the class, method, or field being documented.
    */
    public class FibCalculator extends Fibonacci implements Calculator {

    private static Map<Integer, Integer> memoized = new HashMap<Integer, Integer>();
    public static void main(String[] args) {
    memoized.put(1, 1);
    memoized.put(2, 1);
    System.out.println(fibonacci(12));
    }
    }
    ```

    ## JavaScript


    ```js
    function factorial(n) {
    if (n === 0) {
    return 1; // 0! = 1
    }
    return n * factorial(n - 1);
    }
    ```

    ## JavaScript React (JSX)


    ```jsx
    />
    function Story(props) {
    const SpecificStory = components[props.storyType];
    return story={ props.story } attr2="&ref;" attr3="Hello\n" />;
    }
    ```

    ## JSON


    ```json
    [{
    "hello": "world",
    "count": 1,
    "bool": true
    }]
    ```

    ## Matlab


    ```matlab
    % Numbers _____________________________________________
    5, 5.5, .1, 0.1, 0.4e5, 1.2e-5, 5i, 5.3i, 6j, .345+3i
    5', 5.5', .1', 0.1', 0.4e5', 1.2e-5', 5i', 5.3i', 6j', .345+3i'
    ```

    ## Markdown


    ```markdown
    **bold** `code`
    >
    quote

    ```

    ## Mustache/Handlebars


    ```handlebars
    {{#movie}}

    {{title}}


    src="{{poster}}" alt="{{title}}"/>


    Rating - {{ratings.critics_rating}}

    {{/movie}}
    ```

    ## Perl


    ```perl
    my $var = shift;

    $var =~ s/bla/foo/igs;
    $var =~ s!bla!foo!igs;
    $var =~ s#bla#foo#igs;
    ```

    ## PHP


    ```php
    namespace Application\Controller;

    use Zend\Mvc\Controller\AbstractActionController;

    class IndexController extends AbstractActionController
    {
    }
    ```

    ## Python


    ```python
    def addXToY(x, y):
    total = x + y
    print total
    ```

    ## QML


    ```qml
    Text {
    id: hello
    width: 100
    text: "Hello world!"
    }
    ```

    ## R


    ```r
    # Declare function “f” with parameters “x”, “y“
    # that returns a linear combination of x and y.
    f <- function(x, y) {
    z <- 3 * x + 4 * y
    return(z)
    }
    ```

    +
    ## Raku

    +
    +```raku
    +grammar Parser {
    + rule TOP { I <love> <lang> }
    + token love { '' | love }
    + token lang { < Raku Perl Rust Go Python Ruby > }
    +}
    +
    +say Parser.parse: 'I ♥ Raku';
    +
    +say 1 #`««« blah TODO blah
    +here? »»» 2 ;
    +say 1 #` ( blah TODO blah
    +2 ;
    +rx- regex -
    +```
    +
    ## Ruby


    ```ruby
    require 'Config'
    def CGI::escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
    '%' + $1.unpack('H2' * $1.size).join('%').upcase
    end.tr(' ', '+')
    end
    ```

    ## Rust


    ```rust
    fn main() {
    println!("Hello world!");
    }
    ```

    ## MySQL


    ```mysql
    -- comment
    CREATE TABLE stuff COLUMNS(col1 INT, col2 Varchar);
    SELECT * FROM stuff WHERE id = 'string';
    select * from stuff where id < 0.42;
    Select col1, col2 From stuff Where stuff.col1 IS NOT NuLL;
    ```

    ## TypeScript


    ```ts
    class Student {
    fullName: string;
    constructor(public firstName: string, public middleInitial: string, public lastName: string) {
    this.fullName = firstName + " " + middleInitial + " " + lastName;
    }
    }
    ```

    ## XML


    ```xml
    attribute="3">


    ```

    ## reStructuredText


    ```rst
    Section Header
    ==============

    .. image:: /path/to/image.jpg

    - A bullet list item
    ```

    ## Doxygen


    ```doxygen
    a normal member taking two arguments and returning an integer value.
    @param a an integer argument.
    @param s a constant character pointer.
    @see Javadoc_Test()
    @see publicVar()
    @return The test results
    ```

    ## No language specified


    ```
    No language is specified, but it should be still rendered as code block.
    ```

    # Fenced code blocks with more than 3 backticks or tildes


    ~~~
    Fenced code block with 3 tildes.
    ~~~

    `````````
    Some implementations of Markdown/MultiMarkdown support more than 3 backticks or tildes.
    ```
    The block ends with the same amount of backticks.
    `````````

    ~~~~~~~~~~~~
    Fenced code block with more tildes.
    ~~~~~~~~~~~~

    ## With languages


    ```````html


    class="main">Hello world!




    ```
    ```````

    ~~~bash
    for f *; do
    echo "$f"
    done
    ~~~

    ~~~~~~~~~python
    def addXToY(x, y):
    total = x + y
    print total
    ~~~ # <= doesn't end here
    ~~~~~~~~~

    # Italic and bold text


    **b** *i* __b__ _i_
    ***ib*** ___ib___
    **_ib_** __*ib*__

    * _italic_ **bold** ***ib*** ~~strikeout~~

    >
    _italic_ **bold** ***ib*** ~~strikeout~~

    ## Bold

    **bold*___text** normal
    __bold_***text__ normal

    ## Italic

    *italic _ text* normal
    _italic * text_ normal

    ## Italic-Bold

    ***italic-bold ** italic-bold*** normal
    ***bold-italic text **bold-italic text*** normal
    ***bold*italic*** normal
    **_bold-italic text_** normal


    _ normal text_ * normal text *
    *italic text*normal text*
    *italic text *italic text*
    **bold text**normal text**
    **bold text **bold text**


    aaa**bold text**aaaaa
    aaa__normal text__aaaaa
    пристаням_стремятся_


    \*normal text*
    _normal text\_
    **italic text\**
    ***only bold\***
    **bold\** bold**
    diff --git a/data/syntax/markdown.xml b/data/syntax/markdown.xml index 9b691bb..224b5ba 100644 --- a/data/syntax/markdown.xml +++ b/data/syntax/markdown.xml @@ -1,645 +1,645 @@ ]> - + - + diff --git a/data/syntax/raku.xml b/data/syntax/raku.xml index c2aebff..079db65 100644 --- a/data/syntax/raku.xml +++ b/data/syntax/raku.xml @@ -1,1785 +1,1789 @@ ]+|[&podfmt;](<(?:<*(?=<))|(?![<«])))+"> ]+|[&podfmt;](?![<«])|>(?!>)|<(?!<))+"> 」\]}a-zA-Z0-9]|$))"> «»"> ][+=]|[-&+.<>|^]|cont|elem)\))"> ]+|&bracehyperoperator;)[«»]"> ]|&extrasymboloperators;)[&symboloperators;]*|\(&innerbraceoperator;\)|\[&innerbraceoperator;\]|<[&safesymboloperators;'"]+>)"> ]> - + begin end finish for podtypename pod podtypename True False head1 head2 head3 head4 head5 head6 item item1 item2 item3 item4 item5 item6 para code defn comment table input output exec words quotewords scalar array hash function closure backslash heredoc val macro sub submethod method multi proto only category rule token regex podvalue self let my our state temp has constant if else elsif unless for loop repeat while until gather given take do when next last redo return contend maybe defer default exit make continue break goto leave async lift die fail try warn no use require is as but trusts of returns handles where augment supersede module class role package enum grammar slang subset BEGIN CHECK INIT START FIRST ENTER LEAVE KEEP UNDO NEXT LAST PRE POST END CATCH CONTROL TEMP prec irs ofs ors export deep binary unary reparsed rw parsed cached readonly defequiv will ref copy inline tighter looser equiv assoc required property signature context also shape NaN Inf Object Any Junction Whatever Capture Match Signature Proxy Matcher Package Module Class Grammar Scalar Array Hash KeyHash KeySet KeyBag Pair List Seq Range Set Bag Mapping Void Undef Failure Exception Code Block Routine Sub Macro Method Submethod Regex Str Blob Char Byte Codepoint Grapheme StrPos StrLen Version Num Complex num complex Bit bit bool True False Increasing Decreasing Ordered Callable AnyChar Positional Associative Ordering KeyExtractor Comparator OrderingPair IO KitchenSink Role Int int int1 int2 int4 int8 int16 int32 int64 Rat rat rat1 rat2 rat4 rat8 rat16 rat32 rat64 Buf buf buf1 buf2 buf4 buf8 buf16 buf32 buf64 UInt uint uint1 uint2 uint4 uint8 uint16 uint32 uint64 Abstraction utf8 utf16 utf32 X gcd ge gt lcm le leg let lt map max min minmax mod ne not notandthen o or orelse print push say so substr temp unicmp x xor xx Xeqv Z and andthen any but cmp coll die div does eq eqv ff fff L Letter LC Cased_Letter Lu Uppercase_Letter Ll Lowercase_Letter Lt Titlecase_Letter Lm Modifier_Letter Lo Other_Letter M Mark Mn Nonspacing_Mark Mc Spacing_Mark Me Enclosing_Mark N Number Nd Decimal_Number digit Nl Letter_Number No Other_Number P Punctuation punct Pc Connector_Punctuation Pd Dash_Punctuation Ps Open_Punctuation Pe Close_Punctuation Pi Initial_Punctuation Pf Final_Punctuation Po Other_Punctuation S Symbol Sm Math_Symbol Sc Currency_Symbol Sk Modifier_Symbol So Other_Symbol Z Separator Zs Space_Separator Zl Line_Separator Zp Paragraph_Separator C Other Cc Control cntrl Cf Format Cs Surrogate Co Private_Use Cn Unassigned before after - + + + + + - +