Переглянути джерело

refactor: force brackets in links

Estevao Soares dos Santos 7 роки тому
батько
коміт
be2a10797c

+ 6 - 6
src/converter.js

@@ -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');
         }

+ 1 - 1
test/functional/makemarkdown/cases/standard/anchors-relative.md

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

+ 2 - 2
test/functional/makemarkdown/cases/standard/anchors.md

@@ -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.

+ 1 - 1
test/functional/makemarkdown/cases/standard/emphasis.md

@@ -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>)**

+ 2 - 0
test/functional/makemarkdown/cases/standard/images-followed-by-brackets.html

@@ -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>

+ 3 - 0
test/functional/makemarkdown/cases/standard/images-followed-by-brackets.md

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

+ 4 - 4
test/functional/makemarkdown/cases/standard/images.md

@@ -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]