1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ import * as assert from 'assert' ;
7+ import * as marked from 'marked' ;
8+ import { PlainTextRenderer } from '../../github/markdownUtils' ;
9+
10+ suite ( 'PlainTextRenderer' , ( ) => {
11+ test ( 'should escape inline code by default' , ( ) => {
12+ const renderer = new PlainTextRenderer ( ) ;
13+ const result = marked . parse ( 'rename the `Foo` class' , { renderer, smartypants : true } ) ;
14+ assert . strictEqual ( result . trim ( ) , 'rename the \\`Foo\\` class' ) ;
15+ } ) ;
16+
17+ test ( 'should preserve inline code when allowSimpleMarkdown is true' , ( ) => {
18+ const renderer = new PlainTextRenderer ( true ) ;
19+ const result = marked . parse ( 'rename the `Foo` class' , { renderer, smartypants : true } ) ;
20+ assert . strictEqual ( result . trim ( ) , 'rename the `Foo` class' ) ;
21+ } ) ;
22+
23+ test ( 'should handle multiple inline code spans' , ( ) => {
24+ const renderer = new PlainTextRenderer ( true ) ;
25+ const result = marked . parse ( 'rename the `Foo` class to `Bar`' , { renderer, smartypants : true } ) ;
26+ assert . strictEqual ( result . trim ( ) , 'rename the `Foo` class to `Bar`' ) ;
27+ } ) ;
28+
29+ test ( 'should still escape when allowSimpleMarkdown is false' , ( ) => {
30+ const renderer = new PlainTextRenderer ( false ) ;
31+ const result = marked . parse ( 'rename the `Foo` class to `Bar`' , { renderer, smartypants : true } ) ;
32+ assert . strictEqual ( result . trim ( ) , 'rename the \\`Foo\\` class to \\`Bar\\`' ) ;
33+ } ) ;
34+ } ) ;
0 commit comments