mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
refactor: force brackets in links
This commit is contained in:
parent
94aa3e53ca
commit
be2a10797c
|
@ -368,8 +368,8 @@ showdown.Converter = function (converterOptions) {
|
||||||
clean(doc);
|
clean(doc);
|
||||||
|
|
||||||
// some stuff, like accidental reference links must now be escaped
|
// 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,
|
var nodes = doc.childNodes,
|
||||||
mdDoc = '';
|
mdDoc = '';
|
||||||
|
@ -671,8 +671,8 @@ showdown.Converter = function (converterOptions) {
|
||||||
for (var i = 0; i < childrenLength; ++i) {
|
for (var i = 0; i < childrenLength; ++i) {
|
||||||
txt += parseNode(children[i]);
|
txt += parseNode(children[i]);
|
||||||
}
|
}
|
||||||
txt += ']';
|
txt += '](';
|
||||||
txt += '(' + node.getAttribute('href');
|
txt += '<' + node.getAttribute('href') + '>';
|
||||||
if (node.hasAttribute('title')) {
|
if (node.hasAttribute('title')) {
|
||||||
txt += ' "' + node.getAttribute('title') + '"';
|
txt += ' "' + node.getAttribute('title') + '"';
|
||||||
}
|
}
|
||||||
|
@ -684,8 +684,8 @@ showdown.Converter = function (converterOptions) {
|
||||||
function parseImage (node) {
|
function parseImage (node) {
|
||||||
var txt = '';
|
var txt = '';
|
||||||
if (node.hasAttribute('src')) {
|
if (node.hasAttribute('src')) {
|
||||||
txt += '![' + node.getAttribute('alt') + ']';
|
txt += '![' + node.getAttribute('alt') + '](';
|
||||||
txt += '(' + node.getAttribute('src');
|
txt += '<' + node.getAttribute('src') + '>';
|
||||||
if (node.hasAttribute('width') && node.hasAttribute('height')) {
|
if (node.hasAttribute('width') && node.hasAttribute('height')) {
|
||||||
txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
|
txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
See my [About](/about/) page for details.
|
See my [About](</about/>) page for details.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -68,4 +68,4 @@ foo**bar**baz
|
||||||
|
|
||||||
foo**bar**baz
|
foo**bar**baz
|
||||||
|
|
||||||
this is **[imbued link with strong](//google.com)**
|
this is **[imbued link with strong](<//google.com>)**
|
||||||
|
|
|
@ -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>
|
|
@ -0,0 +1,3 @@
|
||||||
|
![image link](<./image/cat1.png>)(some text between brackets)
|
||||||
|
|
||||||
|
![image link](<./image/cat(1).png>)(some text between brackets)
|
|
@ -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]
|
![leave me alone]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user