This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* MM-19964 Properly handle whitespace before code block language * Update marked to merge commit
- Loading branch information
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {format} from './index'; | ||
|
||
describe('format', () => { | ||
test('should highlight code without space before language', () => { | ||
const output = format(`~~~diff | ||
- something | ||
+ something else | ||
~~~`); | ||
|
||
expect(output).toContain('<span class="post-code__language">Diff</span>'); | ||
expect(output).toContain('<code class="hljs hljs-ln">'); | ||
}); | ||
|
||
test('should highlight code with space before language', () => { | ||
const output = format(`~~~ diff | ||
- something | ||
+ something else | ||
~~~`); | ||
|
||
expect(output).toContain('<span class="post-code__language">Diff</span>'); | ||
expect(output).toContain('<code class="hljs hljs-ln">'); | ||
}); | ||
|
||
test('should not highlight code with an invalid language', () => { | ||
const output = format(`~~~garbage | ||
~~~`); | ||
|
||
expect(output).not.toContain('<span class="post-code__language">'); | ||
}); | ||
}); |