From 4f07626095e66be896549f939b61392e84cd97b6 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:11:30 -0500 Subject: [PATCH 01/10] move rules into constants --- src/languages/markdown.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 7f56f771e0..1d3302448f 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -7,6 +7,20 @@ Category: common, markup */ function(hljs) { + BOLD ={ + className: 'strong', + begin: '[*_]{2}.+?[*_]{2}' + }; + ITALIC = { + className: 'emphasis', + variants: [ + { begin: '\\*.+?\\*' }, + { begin: '_.+?_' + , relevance: 0 + } + ] + }; + return { aliases: ['md', 'mkdown', 'mkd'], contains: [ @@ -29,21 +43,8 @@ function(hljs) { className: 'bullet', begin: '^\\s*([*+-]|(\\d+\\.))\\s+' }, - // strong segments - { - className: 'strong', - begin: '[*_]{2}.+?[*_]{2}' - }, - // emphasis segments - { - className: 'emphasis', - variants: [ - { begin: '\\*.+?\\*' }, - { begin: '_.+?_' - , relevance: 0 - } - ] - }, + BOLD, + ITALIC, // blockquotes { className: 'quote', From 555bc8b8c55eb6b0add901fbbcfa55da910b8312 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:23:58 -0500 Subject: [PATCH 02/10] basic nested bold/italics support --- CHANGES.md | 2 ++ src/languages/markdown.js | 17 +++++++++++------ test/markup/markdown/bold_italics.expect.txt | 7 +++++++ test/markup/markdown/bold_italics.txt | 7 +++++++ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 test/markup/markdown/bold_italics.expect.txt create mode 100644 test/markup/markdown/bold_italics.txt diff --git a/CHANGES.md b/CHANGES.md index a5542c2ccb..6e7bf3c37b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Core Changes: Language Improvements: +- (markdown) improve bold/italic nesting () [Josh Goebel][] - (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) [Sam Miller][] - (delphi) highlight hexadecimal, octal, and binary numbers (#2370) [Robert Riebisch]() - enh(plaintext) added `text` and `txt` as alias (#2360) [Taufik Nurrohman][] @@ -22,6 +23,7 @@ Developer Tools: - none. +[Josh Goebel]: https://github.com/yyyc514 [Sam Miller]: https://github.com/smillerc [Robert Riebisch]: https://github.com/bttrx [Taufik Nurrohman]: https://github.com/taufik-nurrohman diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 1d3302448f..7cd9a97e5e 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -7,19 +7,24 @@ Category: common, markup */ function(hljs) { - BOLD ={ + BOLD = { className: 'strong', - begin: '[*_]{2}.+?[*_]{2}' + contains: [], + variants: [ + {begin: /_{2}/, end: /_{2}/ }, + {begin: /\*{2}/, end: /\*{2}/ } + ] }; ITALIC = { className: 'emphasis', + contains: [], variants: [ - { begin: '\\*.+?\\*' }, - { begin: '_.+?_' - , relevance: 0 - } + { begin: /\*(?!\*)/, end: /\*/ }, + { begin: /_(?!_)/, end: /_/, relevance: 0}, ] }; + BOLD.contains.push(ITALIC); + ITALIC.contains.push(BOLD); return { aliases: ['md', 'mkdown', 'mkd'], diff --git a/test/markup/markdown/bold_italics.expect.txt b/test/markup/markdown/bold_italics.expect.txt new file mode 100644 index 0000000000..7c111c0f94 --- /dev/null +++ b/test/markup/markdown/bold_italics.expect.txt @@ -0,0 +1,7 @@ +_Italic_ +*Italic* +__Bold__ +**Bold** +*Is __Combined__* +__Bold *then italic*__ +**Bold _then italic_** diff --git a/test/markup/markdown/bold_italics.txt b/test/markup/markdown/bold_italics.txt new file mode 100644 index 0000000000..c86f1f326b --- /dev/null +++ b/test/markup/markdown/bold_italics.txt @@ -0,0 +1,7 @@ +_Italic_ +*Italic* +__Bold__ +**Bold** +*Is __Combined__* +__Bold *then italic*__ +**Bold _then italic_** From 00cb57205d90c0f05e3442d1877ae14b35b58746 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:35:15 -0500 Subject: [PATCH 03/10] bold and italic can contain links and html --- src/languages/markdown.js | 70 +++++++++++--------- test/markup/markdown/bold_italics.expect.txt | 2 + test/markup/markdown/bold_italics.txt | 2 + 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 7cd9a97e5e..e87e801383 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -7,6 +7,35 @@ Category: common, markup */ function(hljs) { + INLINE_HTML = { + begin: '<', end: '>', + subLanguage: 'xml', + relevance: 0 + }; + LINK = { + begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]', + returnBegin: true, + contains: [ + { + className: 'string', + begin: '\\[', end: '\\]', + excludeBegin: true, + returnEnd: true, + relevance: 0 + }, + { + className: 'link', + begin: '\\]\\(', end: '\\)', + excludeBegin: true, excludeEnd: true + }, + { + className: 'symbol', + begin: '\\]\\[', end: '\\]', + excludeBegin: true, excludeEnd: true + } + ], + relevance: 10 + }; BOLD = { className: 'strong', contains: [], @@ -26,6 +55,14 @@ function(hljs) { BOLD.contains.push(ITALIC); ITALIC.contains.push(BOLD); + CONTAINABLE = [ + INLINE_HTML, + LINK + ]; + + BOLD.contains = BOLD.contains.concat(CONTAINABLE); + ITALIC.contains = ITALIC.contains.concat(CONTAINABLE); + return { aliases: ['md', 'mkdown', 'mkd'], contains: [ @@ -37,12 +74,7 @@ function(hljs) { { begin: '^.+?\\n[=-]{2,}$' } ] }, - // inline html - { - begin: '<', end: '>', - subLanguage: 'xml', - relevance: 0 - }, + INLINE_HTML, // lists (indicators only) { className: 'bullet', @@ -75,31 +107,7 @@ function(hljs) { { begin: '^[-\\*]{3,}', end: '$' }, - // using links - title and link - { - begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]', - returnBegin: true, - contains: [ - { - className: 'string', - begin: '\\[', end: '\\]', - excludeBegin: true, - returnEnd: true, - relevance: 0 - }, - { - className: 'link', - begin: '\\]\\(', end: '\\)', - excludeBegin: true, excludeEnd: true - }, - { - className: 'symbol', - begin: '\\]\\[', end: '\\]', - excludeBegin: true, excludeEnd: true - } - ], - relevance: 10 - }, + LINK, { begin: /^\[[^\n]+\]:/, returnBegin: true, diff --git a/test/markup/markdown/bold_italics.expect.txt b/test/markup/markdown/bold_italics.expect.txt index 7c111c0f94..b1ec77dfa4 100644 --- a/test/markup/markdown/bold_italics.expect.txt +++ b/test/markup/markdown/bold_italics.expect.txt @@ -5,3 +5,5 @@ *Is __Combined__* __Bold *then italic*__ **Bold _then italic_** +**Bold and <br/>** +**_[this](https://google.com)_** diff --git a/test/markup/markdown/bold_italics.txt b/test/markup/markdown/bold_italics.txt index c86f1f326b..db24156a91 100644 --- a/test/markup/markdown/bold_italics.txt +++ b/test/markup/markdown/bold_italics.txt @@ -5,3 +5,5 @@ __Bold__ *Is __Combined__* __Bold *then italic*__ **Bold _then italic_** +**Bold and
** +**_[this](https://google.com)_** From 38e0d5276f03409afb89ac2a659bd98165497f8b Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:43:06 -0500 Subject: [PATCH 04/10] blockquote can contain other markup --- CHANGES.md | 2 +- src/languages/markdown.js | 19 ++++++++++++++----- test/markup/markdown/bold_italics.expect.txt | 3 +++ test/markup/markdown/bold_italics.txt | 3 +++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6e7bf3c37b..e37e7b576f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,7 +14,7 @@ Core Changes: Language Improvements: -- (markdown) improve bold/italic nesting () [Josh Goebel][] +- (markdown) improve bold/italic nesting (#2382) [Josh Goebel][] - (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) [Sam Miller][] - (delphi) highlight hexadecimal, octal, and binary numbers (#2370) [Robert Riebisch]() - enh(plaintext) added `text` and `txt` as alias (#2360) [Taufik Nurrohman][] diff --git a/src/languages/markdown.js b/src/languages/markdown.js index e87e801383..a9b19e6a16 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -63,6 +63,19 @@ function(hljs) { BOLD.contains = BOLD.contains.concat(CONTAINABLE); ITALIC.contains = ITALIC.contains.concat(CONTAINABLE); + BLOCKQUOTE = { + className: 'quote', + begin: '^>\\s+', + contains: [], + end: '$', + }; + + BLOCKQUOTE.contains = BLOCKQUOTE.contains.concat( + CONTAINABLE, + BOLD, + ITALIC + ) + return { aliases: ['md', 'mkdown', 'mkd'], contains: [ @@ -82,11 +95,7 @@ function(hljs) { }, BOLD, ITALIC, - // blockquotes - { - className: 'quote', - begin: '^>\\s+', end: '$' - }, + BLOCKQUOTE, // code snippets { className: 'code', diff --git a/test/markup/markdown/bold_italics.expect.txt b/test/markup/markdown/bold_italics.expect.txt index b1ec77dfa4..c7804183fb 100644 --- a/test/markup/markdown/bold_italics.expect.txt +++ b/test/markup/markdown/bold_italics.expect.txt @@ -7,3 +7,6 @@ **Bold _then italic_** **Bold and <br/>** **_[this](https://google.com)_** + +> quoted **Bold _then italic_** +> _[this](https://google.com)_ diff --git a/test/markup/markdown/bold_italics.txt b/test/markup/markdown/bold_italics.txt index db24156a91..344bbcae32 100644 --- a/test/markup/markdown/bold_italics.txt +++ b/test/markup/markdown/bold_italics.txt @@ -7,3 +7,6 @@ __Bold *then italic*__ **Bold _then italic_** **Bold and
** **_[this](https://google.com)_** + +> quoted **Bold _then italic_** +> _[this](https://google.com)_ From b1ce165847c26d77a000ce494f8172607263e487 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:51:00 -0500 Subject: [PATCH 05/10] move rest of rules to constants --- src/languages/markdown.js | 99 ++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index a9b19e6a16..42f9cce2ad 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -12,6 +12,51 @@ function(hljs) { subLanguage: 'xml', relevance: 0 }; + HORIZONTAL_RULE = { + begin: '^[-\\*]{3,}', end: '$' + }; + HEADER = { + className: 'section', + variants: [ + { begin: '^#{1,6}', end: '$' }, + { begin: '^.+?\\n[=-]{2,}$' } + ] + }; + CODE = { + className: 'code', + variants: [ + { + begin: '^```\\w*\\s*$', end: '^```[ ]*$' + }, + { + begin: '`.+?`' + }, + { + begin: '^( {4}|\\t)', end: '$', + relevance: 0 + } + ] + }; + LIST = { + className: 'bullet', + begin: '^\\s*([*+-]|(\\d+\\.))\\s+' + }; + LINK_REFERENCE = { + begin: /^\[[^\n]+\]:/, + returnBegin: true, + contains: [ + { + className: 'symbol', + begin: /\[/, end: /\]/, + excludeBegin: true, excludeEnd: true + }, + { + className: 'link', + begin: /:\s*/, end: /$/, + excludeBegin: true + } + ] + }; LINK = { begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]', returnBegin: true, @@ -79,60 +124,16 @@ function(hljs) { return { aliases: ['md', 'mkdown', 'mkd'], contains: [ - // highlight headers - { - className: 'section', - variants: [ - { begin: '^#{1,6}', end: '$' }, - { begin: '^.+?\\n[=-]{2,}$' } - ] - }, + HEADER, INLINE_HTML, - // lists (indicators only) - { - className: 'bullet', - begin: '^\\s*([*+-]|(\\d+\\.))\\s+' - }, + LIST, BOLD, ITALIC, BLOCKQUOTE, - // code snippets - { - className: 'code', - variants: [ - { - begin: '^```\\w*\\s*$', end: '^```[ ]*$' - }, - { - begin: '`.+?`' - }, - { - begin: '^( {4}|\\t)', end: '$', - relevance: 0 - } - ] - }, - // horizontal rules - { - begin: '^[-\\*]{3,}', end: '$' - }, + CODE, + HORIZONTAL_RULE, LINK, - { - begin: /^\[[^\n]+\]:/, - returnBegin: true, - contains: [ - { - className: 'symbol', - begin: /\[/, end: /\]/, - excludeBegin: true, excludeEnd: true - }, - { - className: 'link', - begin: /:\s*/, end: /$/, - excludeBegin: true - } - ] - } + LINK_REFERENCE ] }; } From 8c9eec4215bd696f3eddeca685befe293b014654 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 20:52:50 -0500 Subject: [PATCH 06/10] language should not get bonus points for embedded markdown --- src/languages/dart.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/languages/dart.js b/src/languages/dart.js index cf198cc8ca..bbaa94760a 100644 --- a/src/languages/dart.js +++ b/src/languages/dart.js @@ -92,7 +92,8 @@ function(hljs) { hljs.COMMENT( '/\\*\\*', '\\*/', { - subLanguage: 'markdown' + subLanguage: 'markdown', + relevance:0 } ), hljs.COMMENT( @@ -102,6 +103,7 @@ function(hljs) { subLanguage: 'markdown', begin: '.', end: '$', + relevance:0 }] } ), From 326af4e0d97219256dcdb145c4f5795df7c40ff3 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 21:04:41 -0500 Subject: [PATCH 07/10] headers are also containable --- src/languages/markdown.js | 35 ++++++++++++++---------- test/markup/markdown/sections.expect.txt | 11 ++++++++ test/markup/markdown/sections.txt | 12 ++++++++ 3 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 test/markup/markdown/sections.expect.txt create mode 100644 test/markup/markdown/sections.txt diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 42f9cce2ad..ea02ee98e6 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -15,13 +15,6 @@ function(hljs) { HORIZONTAL_RULE = { begin: '^[-\\*]{3,}', end: '$' }; - HEADER = { - className: 'section', - variants: [ - { begin: '^#{1,6}', end: '$' }, - { begin: '^.+?\\n[=-]{2,}$' } - ] - }; CODE = { className: 'code', variants: [ @@ -108,19 +101,33 @@ function(hljs) { BOLD.contains = BOLD.contains.concat(CONTAINABLE); ITALIC.contains = ITALIC.contains.concat(CONTAINABLE); + CONTAINABLE = CONTAINABLE.concat(BOLD,ITALIC); + + HEADER = { + className: 'section', + variants: [ + { + begin: '^#{1,6}', + end: '$', + contains: CONTAINABLE + }, + { + begin: '(?=^.+?\\n[=-]{2,}$)', + contains: [ + { begin: '^[=-]*$' }, + { begin: '^', end: "\\n", contains: CONTAINABLE }, + ] + } + ] + }; + BLOCKQUOTE = { className: 'quote', begin: '^>\\s+', - contains: [], + contains: CONTAINABLE, end: '$', }; - BLOCKQUOTE.contains = BLOCKQUOTE.contains.concat( - CONTAINABLE, - BOLD, - ITALIC - ) - return { aliases: ['md', 'mkdown', 'mkd'], contains: [ diff --git a/test/markup/markdown/sections.expect.txt b/test/markup/markdown/sections.expect.txt new file mode 100644 index 0000000000..36093ec8a7 --- /dev/null +++ b/test/markup/markdown/sections.expect.txt @@ -0,0 +1,11 @@ +# hello world + +## hello world + +hello world +=========== + +*hello world* or [google](link) +=========== + +# *hello world* or [google](link) diff --git a/test/markup/markdown/sections.txt b/test/markup/markdown/sections.txt new file mode 100644 index 0000000000..2dfe138e9f --- /dev/null +++ b/test/markup/markdown/sections.txt @@ -0,0 +1,12 @@ +# hello world + +## hello world + +hello world +=========== + +*hello world* or [google](link) +=========== + +# *hello world* or [google](link) + From 43e5d3058b9edfa60ab6cbdb843a1c9381b30497 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 21:36:51 -0500 Subject: [PATCH 08/10] much better code block support --- CHANGES.md | 1 + src/languages/markdown.js | 20 ++++++++++------ test/markup/markdown/code.expect.txt | 34 ++++++++++++++++++++++++++-- test/markup/markdown/code.txt | 30 ++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e37e7b576f..a95c64b6f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Core Changes: Language Improvements: +- (markdown) much improved code block support (#2382) [Josh Goebel][] - (markdown) improve bold/italic nesting (#2382) [Josh Goebel][] - (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) [Sam Miller][] - (delphi) highlight hexadecimal, octal, and binary numbers (#2370) [Robert Riebisch]() diff --git a/src/languages/markdown.js b/src/languages/markdown.js index ea02ee98e6..7706ff062c 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -18,14 +18,20 @@ function(hljs) { CODE = { className: 'code', variants: [ + // TODO: fix to allow these to work with sublanguage also + { begin: '(`{3,})(.|\\n)*?\\1`*[ ]*', }, + { begin: '(~{3,})(.|\\n)*?\\1~*[ ]*', }, + // needed to allow markdown as a sublanguage to work + { begin: '```', end: '```+[ ]*$' }, + { begin: '~~~', end: '~~~+[ ]*$' }, + { begin: '`.+?`' }, { - begin: '^```\\w*\\s*$', end: '^```[ ]*$' - }, - { - begin: '`.+?`' - }, - { - begin: '^( {4}|\\t)', end: '$', + begin: '(?=^( {4}|\\t))', + // use contains to gobble up multiple lines to allow the block to be whatever size + // but only have a single open/close tag vs one per line + contains: [ + { begin: '^( {4}|\\t)', end: '(\\n)$' } + ], relevance: 0 } ] diff --git a/test/markup/markdown/code.expect.txt b/test/markup/markdown/code.expect.txt index 881ec4420e..c50bd78a60 100644 --- a/test/markup/markdown/code.expect.txt +++ b/test/markup/markdown/code.expect.txt @@ -1,8 +1,38 @@ - var code = true; - + var code = true; + var code = false; + ```javascript var code = true; ``` +````md +``` +a = 'This is a code block in python' +``` +```` + +~~~ +tilde can be used also (github) +~~~ + +~~~~ ruby startline=3 $%@#$ +def foo(x) + return 3 +end +~~~~~~~ + +~~~~~~~something +code here +~~~~~~~ + +``` +aaa +~~~ +``` + + ```javascript + can be indented + ``` + Inline `code`, and `more code`. diff --git a/test/markup/markdown/code.txt b/test/markup/markdown/code.txt index d9bed99184..e095534bc0 100644 --- a/test/markup/markdown/code.txt +++ b/test/markup/markdown/code.txt @@ -1,8 +1,38 @@ var code = true; + var code = false; ```javascript var code = true; ``` +````md +``` +a = 'This is a code block in python' +``` +```` + +~~~ +tilde can be used also (github) +~~~ + +~~~~ ruby startline=3 $%@#$ +def foo(x) + return 3 +end +~~~~~~~ + +~~~~~~~something +code here +~~~~~~~ + +``` +aaa +~~~ +``` + + ```javascript + can be indented + ``` + Inline `code`, and `more code`. From 33b60ce91e2d7c612bdfa3538dc3f3a05fc31d26 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 21:49:36 -0500 Subject: [PATCH 09/10] test emphasis vs bullets --- src/languages/markdown.js | 2 +- test/markup/markdown/bold_italics.expect.txt | 6 ++++++ test/markup/markdown/bold_italics.txt | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index 7706ff062c..a381ca3095 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -38,7 +38,7 @@ function(hljs) { }; LIST = { className: 'bullet', - begin: '^\\s*([*+-]|(\\d+\\.))\\s+' + begin: '^[ \t]*([*+-]|(\\d+\\.))\\s+' }; LINK_REFERENCE = { begin: /^\[[^\n]+\]:/, diff --git a/test/markup/markdown/bold_italics.expect.txt b/test/markup/markdown/bold_italics.expect.txt index c7804183fb..5a71575c89 100644 --- a/test/markup/markdown/bold_italics.expect.txt +++ b/test/markup/markdown/bold_italics.expect.txt @@ -10,3 +10,9 @@ > quoted **Bold _then italic_** > _[this](https://google.com)_ + + *this is a emphasized paragraph* + *this is too* + +* list with a *italic item* +* list with a **bold item** diff --git a/test/markup/markdown/bold_italics.txt b/test/markup/markdown/bold_italics.txt index 344bbcae32..2b72d45cdd 100644 --- a/test/markup/markdown/bold_italics.txt +++ b/test/markup/markdown/bold_italics.txt @@ -10,3 +10,9 @@ __Bold *then italic*__ > quoted **Bold _then italic_** > _[this](https://google.com)_ + + *this is a emphasized paragraph* + *this is too* + +* list with a *italic item* +* list with a **bold item** From 92ba8a6eeb2ea25c909c1e1d504c7a9f2afe9cc3 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Fri, 31 Jan 2020 21:56:12 -0500 Subject: [PATCH 10/10] remove space from end of bullets --- src/languages/markdown.js | 4 +++- test/markup/markdown/bold_italics.expect.txt | 4 ++-- test/markup/markdown/list.expect.txt | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/languages/markdown.js b/src/languages/markdown.js index a381ca3095..e84cf9bc35 100644 --- a/src/languages/markdown.js +++ b/src/languages/markdown.js @@ -38,7 +38,9 @@ function(hljs) { }; LIST = { className: 'bullet', - begin: '^[ \t]*([*+-]|(\\d+\\.))\\s+' + begin: '^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)', + end: '\\s+', + excludeEnd: true }; LINK_REFERENCE = { begin: /^\[[^\n]+\]:/, diff --git a/test/markup/markdown/bold_italics.expect.txt b/test/markup/markdown/bold_italics.expect.txt index 5a71575c89..fee002a4a5 100644 --- a/test/markup/markdown/bold_italics.expect.txt +++ b/test/markup/markdown/bold_italics.expect.txt @@ -14,5 +14,5 @@ *this is a emphasized paragraph* *this is too* -* list with a *italic item* -* list with a **bold item** +* list with a *italic item* +* list with a **bold item** diff --git a/test/markup/markdown/list.expect.txt b/test/markup/markdown/list.expect.txt index 497d464750..64b2341b18 100644 --- a/test/markup/markdown/list.expect.txt +++ b/test/markup/markdown/list.expect.txt @@ -1,5 +1,5 @@ -- this is a list -- this is another - - nested list - - another nested - * nested alternative +- this is a list +- this is another + - nested list + - another nested + * nested alternative