@@ -384,6 +384,41 @@ describe('paste-markdown', function () {
384384 paste ( textarea , { 'text/html' : sentence , 'text/plain' : plaintextSentence } )
385385 assert . equal ( textarea . value , markdownSentence )
386386 } )
387+
388+ it ( 'pastes markdown with multiple links and labels correctly' , function ( ) {
389+ // eslint-disable-next-line i18n-text/no-en
390+ const commonSentence = 'Great example for example resources for developers'
391+ // eslint-disable-next-line github/unescaped-html-literal
392+ const sentence = `<meta charset='utf-8'><span>
393+ ${ commonSentence } : <a href="https://www.example.com/">example</a> and <a href="https://www.example.com/">example</a>.</span>`
394+ const plaintextSentence = `${ commonSentence } : example and example.`
395+ const markdownSentence = `${ commonSentence } : [example](https://www.example.com/) and [example](https://www.example.com/).`
396+
397+ paste ( textarea , { 'text/html' : sentence , 'text/plain' : plaintextSentence } )
398+ assert . equal ( textarea . value , markdownSentence )
399+ } )
400+
401+ it ( 'pastes markdown with link labels that contains special characters in html' , function ( ) {
402+ // eslint-disable-next-line github/unescaped-html-literal
403+ const sentence = `<meta charset='utf-8'>
404+ <a href="https://www.abcxyz.org/">foo bar</a> <a href="https://example.com/?q=foo&bar=baz">foo&bar</a>`
405+ const plaintextSentence = 'foo bar foo&bar'
406+ const markdownSentence = '[foo bar](https://www.abcxyz.org/) [foo&bar](https://example.com/?q=foo&bar=baz)'
407+
408+ paste ( textarea , { 'text/html' : sentence , 'text/plain' : plaintextSentence } )
409+ assert . equal ( textarea . value , markdownSentence )
410+ } )
411+
412+ it ( 'pastes markdown with link labels that contains emojis in html' , function ( ) {
413+ // eslint-disable-next-line github/unescaped-html-literal
414+ const sentence = `<meta charset='utf-8'>
415+ <p>foo bar <a href="https://www.abcxyz.org/">foo</a> bar foo <a href="https://example.com/">π bar π</a></p>`
416+ const plaintextSentence = 'foo bar foo bar foo π bar π'
417+ const markdownSentence = 'foo bar [foo](https://www.abcxyz.org/) bar foo [π bar π](https://example.com/)'
418+
419+ paste ( textarea , { 'text/html' : sentence , 'text/plain' : plaintextSentence } )
420+ assert . equal ( textarea . value , markdownSentence )
421+ } )
387422 } )
388423} )
389424
0 commit comments