Skip to content

Commit

Permalink
fix a tag [content](link "title")
Browse files Browse the repository at this point in the history
  • Loading branch information
Zjmainstay committed Jul 21, 2014
1 parent dda7f2c commit 93d2ea9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions markdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ function parseMarkdown($doc) {
//img
$doc = preg_replace('#!\[([^\]]*?)\]\(([^\s]*?)(?: "([^"]*?)")?\)#is', '<img src="\2" alt="\1" title="\3" />', $doc);

//a simple
if(preg_match_all('#\[([^\]]*?)\]\(([^\s]*?)(?:\s"([^"]*?)")?\)#is', $doc, $links)) {
$linkTpl = '<a target="_blank" href="%s" title="%s">%s</a>';
foreach($links[0] as $key => $value) {
$doc = str_replace($links[0][$key], sprintf($linkTpl, $links[2][$key], $links[3][$key], $links[1][$key]), $doc);
}
}

//a normal
if(preg_match_all('#\[([^\]]*?)\]\[(\d+)\]#is', $doc, $links)) {
$linkTpl = '<a target="_blank" href="%s">%s</a>';
Expand Down

0 comments on commit 93d2ea9

Please sign in to comment.