Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
For the purpose of this plugin, autolinking from markdown to html is …
Browse files Browse the repository at this point in the history
…wrong.
  • Loading branch information
fredck committed Feb 25, 2020
1 parent b0a9811 commit a54e9fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
6 changes: 6 additions & 0 deletions src/markdown2html/markdown2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ export default function markdown2html( markdown ) {
headerIds: false
} );
}

// Overrides.

// Disable the autolink rule in the lexer (point it to a regex that always fail).
marked.InlineLexer.rules.breaks.autolink = /^\b$/;
marked.InlineLexer.rules.breaks.url = /^\b$/;
45 changes: 11 additions & 34 deletions tests/gfmdataprocessor/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,34 @@ import { testDataProcessor as test } from '../../tests/_utils/utils';

describe( 'GFMDataProcessor', () => {
describe( 'links', () => {
it( 'should autolink', () => {
test(
'Link: <http://example.com/>.',
'<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>',

// When converting back it will be represented as standard markdown link.
'Link: [http://example.com/](http://example.com/).'
);
} );

it( 'should autolink #2', () => {
it( 'should not autolink', () => {
test(
'Link: http://example.com/.',
'<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>',

// When converting back it will be represented as standard markdown link.
'Link: [http://example.com/](http://example.com/).'
'<p>Link: http://example.com/.</p>'
);
} );

it( 'should autolink with params', () => {
it( 'should not autolink with params', () => {
test(
'Link: <http://example.com/?foo=1&bar=2>.',
'<p>Link: <a href="http://example.com/?foo=1&bar=2">http://example.com/?foo=1&bar=2</a>.</p>',

// When converting back it will be represented as standard markdown link.
'Link: [http://example.com/?foo=1&bar=2](http://example.com/?foo=1&bar=2).'
'Link: http://example.com/?foo=1&bar=2.',
'<p>Link: http://example.com/?foo=1&bar=2.</p>'
);
} );

it( 'should autolink inside list', () => {
it( 'should not autolink inside list', () => {
test(
'* <http://example.com/>',

'<ul><li><a href="http://example.com/">http://example.com/</a></li></ul>',

// When converting back it will be represented as standard markdown link.
'* [http://example.com/](http://example.com/)'
'* http://example.com/',
'<ul><li>http://example.com/</li></ul>',
);
} );

it( 'should autolink inside blockquote', () => {
it( 'should not autolink inside blockquote', () => {
test(
'> Blockquoted: <http://example.com/>',
'> Blockquoted: http://example.com/',

'<blockquote>' +
'<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>' +
'<p>Blockquoted: http://example.com/</p>' +
'</blockquote>',

// When converting back it will be represented as standard markdown link.
'> Blockquoted: [http://example.com/](http://example.com/)'
);
} );

Expand Down

0 comments on commit a54e9fc

Please sign in to comment.