Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown: Nested lists #2228

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions components/prism-markdown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function (Prism) {

// Allow only one line break
var inner = /(?:\\.|[^\\\n\r]|(?:\r?\n|\r)(?!\r?\n|\r))/.source;
var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?!\n|\r\n?))/.source;

/**
* This function is intended for the creation of the bold or italic pattern.
Expand All @@ -24,8 +24,8 @@


var tableCell = /(?:\\.|``.+?``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
var tableRow = /\|?__(?:\|__)+\|?(?:(?:\r?\n|\r)|$)/.source.replace(/__/g, tableCell);
var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\r?\n|\r)/.source;
var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|$)/.source.replace(/__/g, tableCell);
var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;


Prism.languages.markdown = Prism.languages.extend('markup', {});
Expand Down Expand Up @@ -72,7 +72,7 @@
'code': [
{
// Prefixed by 4 spaces or 1 tab and preceded by an empty line
pattern: /(^[ \t]*(?:\r?\n|\r))(?: {4}|\t).+(?:(?:\r?\n|\r)(?: {4}|\t).+)*/m,
pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
lookbehind: true,
alias: 'keyword'
},
Expand All @@ -90,7 +90,7 @@
greedy: true,
inside: {
'code-block': {
pattern: /^(```.*(?:\r?\n|\r))[\s\S]+?(?=(?:\r?\n|\r)^```$)/m,
pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,
lookbehind: true
},
'code-language': {
Expand All @@ -108,7 +108,7 @@

// title 2
// -------
pattern: /\S.*(?:\r?\n|\r)(?:==+|--+)(?=[ \t]*$)/m,
pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
alias: 'important',
inside: {
punctuation: /==+$|--+$/
Expand Down
2 changes: 1 addition & 1 deletion components/prism-markdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 31 additions & 7 deletions tests/languages/markdown/list_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,41 @@
2. bar
42. baz

1. list
1. nested list
- a
- b
2. foo

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

[
["list", "*"], " foo\r\n",
["list", "+"], " bar\r\n",
["list", "-"], " baz\r\n\r\n",
["list", "1."], " foo\r\n ",
["list", "2."], " bar\r\n",
["list", "42."], " baz"
["list", "*"],
" foo\r\n",
["list", "+"],
" bar\r\n",
["list", "-"],
" baz\r\n\r\n",

["list", "1."],
" foo\r\n ",
["list", "2."],
" bar\r\n",
["list", "42."],
" baz\r\n\r\n",

["list", "1."],
" list\r\n\t",
["list", "1."],
" nested list\r\n\t\t",
["list", "-"],
" a\r\n\t\t",
["list", "-"],
" b\r\n\t",
["list", "2."],
" foo"
]

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

Checks for list symbols.
Checks for list symbols.