소스 검색

fix(subParsers/images.js): fix empty title attribute in img tags

This big was introduced on purpose to mimic markdown.pl. Since we no longer match our development with that library,
it makes no sense to keep it.
Estevao Soares dos Santos 10 년 전
부모
커밋
e27e16bdc5
5개의 변경된 파일14개의 추가작업 그리고 20개의 파일을 삭제
  1. 9 12
      dist/showdown.js
  2. 0 0
      dist/showdown.js.map
  3. 0 0
      dist/showdown.min.js
  4. 0 0
      dist/showdown.min.js.map
  5. 5 8
      src/subParsers/images.js

+ 9 - 12
dist/showdown.js

@@ -1439,14 +1439,14 @@ showdown.subParser('headers', function (text, options, globals) {
   text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm, function (wholeMatch, m1) {
 
     var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
-        hID = (options.noHeaderId) ? '' : 'id="' + headerId(m1) + '"',
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
         hashBlock = '<h1' + hID + '>' + spanGamut + '</h1>';
     return showdown.subParser('hashBlock')(hashBlock, options, globals);
   });
 
   text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, function (matchFound, m1) {
     var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
-        hID = (options.noHeaderId) ? '' : 'id="' + headerId(m1) + '"',
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
         hashBlock = '<h2' + hID + '>' + spanGamut + '</h2>';
     return showdown.subParser('hashBlock')(hashBlock, options, globals);
   });
@@ -1470,9 +1470,9 @@ showdown.subParser('headers', function (text, options, globals) {
    /gm, function() {...});
    */
 
-  text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function (wholeMatch, m1, m2) {
+  text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
     var span = showdown.subParser('spanGamut')(m2, options, globals),
-        hID = (options.noHeaderId) ? '' : 'id="' + headerId(m1) + '"',
+        hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
         header = '<h' + m1.length + hID + '>' + span + '</h' + m1.length + '>';
 
     return showdown.subParser('hashBlock')(header, options, globals);
@@ -1543,14 +1543,11 @@ showdown.subParser('images', function (text, options, globals) {
     url = showdown.helper.escapeCharacters(url, '*_', false);
     var result = '<img src="' + url + '" alt="' + altText + '"';
 
-    // attacklab: Markdown.pl adds empty title attributes to images.
-    // Replicate this bug.
-
-    //if (title != "") {
-    title = title.replace(/"/g, '&quot;');
-    title = showdown.helper.escapeCharacters(title, '*_', false);
-    result += ' title="' + title + '"';
-    //}
+    if (title != "") {
+      title = title.replace(/"/g, '&quot;');
+      title = showdown.helper.escapeCharacters(title, '*_', false);
+      result += ' title="' + title + '"';
+    }
 
     result += ' />';
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.js.map


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.min.js.map


+ 5 - 8
src/subParsers/images.js

@@ -39,14 +39,11 @@ showdown.subParser('images', function (text, options, globals) {
     url = showdown.helper.escapeCharacters(url, '*_', false);
     var result = '<img src="' + url + '" alt="' + altText + '"';
 
-    // attacklab: Markdown.pl adds empty title attributes to images.
-    // Replicate this bug.
-
-    //if (title != "") {
-    title = title.replace(/"/g, '&quot;');
-    title = showdown.helper.escapeCharacters(title, '*_', false);
-    result += ' title="' + title + '"';
-    //}
+    if (title != "") {
+      title = title.replace(/"/g, '&quot;');
+      title = showdown.helper.escapeCharacters(title, '*_', false);
+      result += ' title="' + title + '"';
+    }
 
     result += ' />';
 

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.