Skip to content

Commit

Permalink
remove hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Jul 2, 2016
1 parent 85cadd6 commit 41c3354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ rules.link_open = function(tokens, idx /*, options, env */) {
if (close.type === 'link_close' && after && after.type === 'text') {
var str = after.content;
var hasBrace = str.charAt(0) === '{';
var i = str.indexOf('#');
if (str && hasBrace && i !== -1) {
if (str && hasBrace) {
var end = str.indexOf('}');
var href = str.slice(1, end);

after.content = str.slice(end + 1).trim();
if (after.content) {
after.content = ' ' + after.content;
Expand All @@ -226,7 +224,7 @@ rules.link_open = function(tokens, idx /*, options, env */) {
}

// console.log(token.href)
var anchor = /\{(#[^}]+)\}/.exec(token.href);
var anchor = /\{([^}]+)\}/.exec(token.href);
if (anchor && anchor[1]) {
token.href = token.href.replace(anchor[0], anchor[1]);
}
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ describe('prettify', function() {
var str = '[![foo](https://a.b.c.svg)](http://a.b.c){#zzz}';
assert.equal(pretty(str), '[![foo](https://a.b.c.svg)](http://a.b.c#zzz)');
});

it('should use paths with badges:', function() {
var str = '[![foo](https://a.b.c.svg)](http://a.b.c){/zzz}';
assert.equal(pretty(str), '[![foo](https://a.b.c.svg)](http://a.b.c/zzz)');
});
});

describe('images', function() {
Expand Down

0 comments on commit 41c3354

Please # to comment.