diff --git a/autotests/folding/example.rmd.fold b/autotests/folding/example.rmd.fold --- a/autotests/folding/example.rmd.fold +++ b/autotests/folding/example.rmd.fold @@ -1,24 +1,24 @@ ---- -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) { +```{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. @@ -37,3 +37,32 @@ * 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 --- a/autotests/folding/test.markdown.fold +++ b/autotests/folding/test.markdown.fold @@ -1,3 +1,11 @@ +--- +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 @@ -22,8 +30,36 @@ 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 @@ -38,145 +74,509 @@ 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 +```bash #!/usr/bin/env bash -for f in *; do +for f in *; do echo "$f" -done -``` +done +``` ## C++ -```cpp +```cpp #include -class Q : public QObject { +class Q : public QObject { Q_OBJECT public: Q(); -} +} -Q::Q() :QObject(NULL) { -} -``` +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 cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project (hello_world) set(QT_MIN_VERSION "5.6.0") -``` +``` ## CSS -```css -h1.main::hover { +```css +h1.main::hover { font-size: 100; color: green; -} -``` +} +``` ## Email -```email +```email From: Konqi Dragon To: All Subject: highlights -``` +``` + +## Go + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Hola, mundo.") +} +``` ## Haskell -```haskell +```haskell module Main (main) where main :: IO () main = putStrLn "Hello, World!" -``` +``` ## HTML -```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 -[{ +```json +[{ "hello": "world", "count": 1, "bool": true -}] -``` +}] +``` -## KConfig +## Matlab -```kconfig -[General] -Toggle=true -Count=1 -``` +```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 +```php namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; class IndexController extends AbstractActionController -{ -} -``` +{ +} +``` ## Python -```python -def addXToY(x, y): +```python +def addXToY(x, y): total = x + y print total -``` +``` ## QML -```qml -Text { +```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) +} +``` + +## 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() { +```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"> - /> -> -``` +```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 + + +

    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/basic.markdown.html b/autotests/html/basic.markdown.html --- a/autotests/html/basic.markdown.html +++ b/autotests/html/basic.markdown.html @@ -6,8 +6,8 @@
     normal
     
    -* item1
    -still part of item
    +* item1
    +still part of item
     
     normal text again
     
    diff --git a/autotests/html/example.rmd.html b/autotests/html/example.rmd.html --- a/autotests/html/example.rmd.html +++ b/autotests/html/example.rmd.html @@ -26,21 +26,50 @@ 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. +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 + * kate + * vim + * emacs -*italic*, **bold**, `monospace` +*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/html/test.markdown.html b/autotests/html/test.markdown.html --- a/autotests/html/test.markdown.html +++ b/autotests/html/test.markdown.html @@ -4,6 +4,14 @@ 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
    @@ -16,33 +24,173 @@
     Intentional line break  
     via two spaces at line.
     
    -Formats: _italic_, **bold**, `monospace`, ~~strikeout~~
    +Formats: _italic_, **bold**, `monospace`, ~~strikeout~~
     
     Bullet list:
     
    -* item1
    -* item2
    +* item1
    +* item2
     
     Numbered list:
     
    -1. item 1
    -2. item 2
    +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.
     
    -[link](http://kde.org)
    +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
    +> block quote _italic_
    +> more block quote
     
     normal text
     
    -Title: some 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)
     
    @@ -71,6 +219,24 @@
     }
     ```
     
    +## 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
    @@ -98,6 +264,18 @@
     Subject: highlights
     ```
     
    +## Go
    +
    +```go
    +package main
    +
    +import "fmt"
    +
    +func main() {
    +  fmt.Println("Hola, mundo.")
    +}
    +```
    +
     ## Haskell
     
     ```haskell
    @@ -117,6 +295,48 @@
     </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
    @@ -127,12 +347,44 @@
     }]
     ```
     
    -## KConfig
    +## 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
    +
    +```
     
    -```kconfig
    -[General]
    -Toggle=true
    -Count=1
    +## 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
    @@ -165,25 +417,173 @@
     }
     ```
     
    +## 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)
    +}
    +```
    +
    +## 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/example.rmd b/autotests/input/example.rmd --- a/autotests/input/example.rmd +++ b/autotests/input/example.rmd @@ -37,3 +37,32 @@ * 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/input/test.markdown b/autotests/input/test.markdown --- a/autotests/input/test.markdown +++ b/autotests/input/test.markdown @@ -1,3 +1,11 @@ +--- +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 @@ -22,8 +30,36 @@ 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 @@ -38,6 +74,118 @@ 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 + + + + + + + + + + +
    ab
      +
    • 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 @@ -65,6 +213,24 @@ } ``` +## 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 @@ -92,6 +258,18 @@ Subject: highlights ``` +## Go + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Hola, mundo.") +} +``` + ## Haskell ```haskell @@ -111,6 +289,48 @@ ``` +## 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 @@ -121,12 +341,44 @@ }] ``` -## KConfig +## 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 + +``` -```kconfig -[General] -Toggle=true -Count=1 +## 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 @@ -159,24 +411,172 @@ } ``` +## 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) +} +``` + +## 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/basic.markdown.ref b/autotests/reference/basic.markdown.ref --- a/autotests/reference/basic.markdown.ref +++ b/autotests/reference/basic.markdown.ref @@ -1,6 +1,6 @@ normal

    -* item1
    -still part of item
    -
    +* item1
    +still part of item
    +
    normal text again
    diff --git a/autotests/reference/example.rmd.ref b/autotests/reference/example.rmd.ref --- a/autotests/reference/example.rmd.ref +++ b/autotests/reference/example.rmd.ref @@ -20,20 +20,49 @@ 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.
    +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.
    +Inline `y <- 5 + x - sin(3)` code.


    Heading
    - =======
    +
    =======


    Sub-heading
    - -----------
    + -----------
    A list of editors:
    - * kate
    - * vim
    - * emacs
    + * kate
    + * vim
    + * emacs
    +
    +*italic*, **bold**, `monospace`

    -*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/reference/test.markdown.ref b/autotests/reference/test.markdown.ref --- a/autotests/reference/test.markdown.ref +++ b/autotests/reference/test.markdown.ref @@ -1,58 +1,206 @@ -

    # H1


    +---
    +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.
    +---

    -

    ## H2


    +
    # H1


    -

    ### H3


    +
    ## H2

    +
    +
    ### H3


    Multi-line paragraph bla bla bla
    bla bla bla.

    -Intentional line break
    +Intentional line break
    via two spaces at line.

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

    Bullet list:

    -* item1
    -* item2
    -
    +* item1
    +* item2
    +
    Numbered list:

    -1. item 1
    -2. item 2
    +1. item 1
    +2. item 2
    +
    +Task list:

    -[link](http://kde.org)
    +- [x] Finish my changes
    +- [ ] Push my commits
    +- [ ] Open a pull request
    +
    +A link as normal text: http://example.com

    - code 1
    - code 2
    +[link](http://kde.org)

    -normal text
    +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")

    -
    > block quote
    _italic_
    -
    > more block quote

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

    normal text

    -Title: some text
    +
    >
    block quote _italic_
    +
    >
    more block quote

    normal text

    -

    # Fenced code blocks (bug 356974)


    +Title: some text
    +
    +normal text

    -

    ## Bash


    +
    # 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
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    ab

      +
    • c

    • +
    • d

    • +
    e

    +
    +normal text *italic*
    +
    +
    # Code

    +
    +`simple code`
    +
    +``simple ` code``
    +
    +```simple `` ` code ```
    +
    +````simple`code````

    -```bash
    +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++


    +
    ## C++


    -```cpp
    +```cpp
    #include

    class Q : public QObject {
    @@ -63,120 +211,372 @@
    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
    +```cmake
    cmake_minimum_required(VERSION 3.10 FATAL_ERROR)

    project (hello_world)

    set(QT_MIN_VERSION "5.6.0")
    -```
    +```

    -

    ## CSS


    +
    ## CSS


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

    -

    ## Email


    +
    ## Email


    -```email
    +```email
    From: Konqi Dragon

    To: All

    Subject: highlights
    -```
    +```

    -

    ## Haskell


    +
    ## Go


    -```haskell
    +```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
    +```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);
    +}
    +```

    -

    ## JSON


    +
    ## JavaScript React (JSX)


    -```json
    +```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
    +
    +```

    -

    ## KConfig


    +
    ## Mustache/Handlebars


    -```kconfig
    -[General]
    -Toggle=true
    -Count=1
    -```
    +```handlebars
    +{{#movie}}
    +

    +

    {{title}}


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

    +

    + Rating - {{ratings.critics_rating}}
    +

    +{{/movie}}
    +```

    -

    ## PHP


    +
    ## Perl


    -```php
    +```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


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

    -

    ## QML


    +
    ## QML


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

    -

    ## Rust


    +
    ## 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)
    +}
    +```

    -```rust
    +
    ## 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


    -```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.
    +```

    -

    ## No language specified


    +
    # Fenced code blocks with more than 3 backticks or tildes


    -```
    -No language is specified, but it should be still rendered as code block.
    -```
    +~~~
    +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 --- a/data/syntax/markdown.xml +++ b/data/syntax/markdown.xml @@ -6,6 +6,7 @@ Dual-Licensed under both GPL and BSD licenses. Extended 2009 Claes Holmerson. http://github.com/claes/kate-markdown/ + Extended 2019 Nibaldo González S. (changes under MIT license). --> - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + ]> - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + + + + + - - + + + + + + - - + + + + + + - - + + + + + + + + + + - - + + - - + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + + + + + + + + + + + + + - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/data/syntax/rmarkdown.xml b/data/syntax/rmarkdown.xml --- a/data/syntax/rmarkdown.xml +++ b/data/syntax/rmarkdown.xml @@ -1,5 +1,13 @@ - + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +