refactor: force brackets in links

This commit is contained in:
Estevao Soares dos Santos 2017-12-23 12:41:21 +00:00
parent 94aa3e53ca
commit be2a10797c
7 changed files with 19 additions and 14 deletions

View File

@ -368,8 +368,8 @@ showdown.Converter = function (converterOptions) {
clean(doc);
// some stuff, like accidental reference links must now be escaped
doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
// TODO
// doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
var nodes = doc.childNodes,
mdDoc = '';
@ -671,8 +671,8 @@ showdown.Converter = function (converterOptions) {
for (var i = 0; i < childrenLength; ++i) {
txt += parseNode(children[i]);
}
txt += ']';
txt += '(' + node.getAttribute('href');
txt += '](';
txt += '<' + node.getAttribute('href') + '>';
if (node.hasAttribute('title')) {
txt += ' "' + node.getAttribute('title') + '"';
}
@ -684,8 +684,8 @@ showdown.Converter = function (converterOptions) {
function parseImage (node) {
var txt = '';
if (node.hasAttribute('src')) {
txt += '![' + node.getAttribute('alt') + ']';
txt += '(' + node.getAttribute('src');
txt += '![' + node.getAttribute('alt') + '](';
txt += '<' + node.getAttribute('src') + '>';
if (node.hasAttribute('width') && node.hasAttribute('height')) {
txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
}

View File

@ -1 +1 @@
See my [About](/about/) page for details.
See my [About](</about/>) page for details.

View File

@ -1,3 +1,3 @@
This is [an example](http://example.com/ "Title") inline link.
This is [an example](<http://example.com/> "Title") inline link.
[This link](http://example.net/) has no title attribute.
[This link](<http://example.net/>) has no title attribute.

View File

@ -68,4 +68,4 @@ foo**bar**baz
foo**bar**baz
this is **[imbued link with strong](//google.com)**
this is **[imbued link with strong](<//google.com>)**

View File

@ -0,0 +1,2 @@
<p><img src="./image/cat1.png" alt="image link" />(some text between brackets)</p>
<p><img src="./image/cat(1).png" alt="image link" />(some text between brackets)</p>

View File

@ -0,0 +1,3 @@
![image link](<./image/cat1.png>)(some text between brackets)
![image link](<./image/cat(1).png>)(some text between brackets)

View File

@ -1,10 +1,10 @@
![Alt text](/path/to/img.jpg)
![Alt text](</path/to/img.jpg>)
![Alt text](/path/to/img.jpg "Optional title")
![Alt text](</path/to/img.jpg> "Optional title")
![Alt text](url/to/image.jpg "Optional title attribute")
![Alt text](<url/to/image.jpg> "Optional title attribute")
![My Image](url/to/image2.jpg "Optional title attribute")
![My Image](<url/to/image2.jpg> "Optional title attribute")
![leave me alone]