PEAR2_Text_Markdown › PEAR2_Text_Markdown-0.1.0/php/PEAR2/Text/Markdown/Apidoc/Link.php
- PEAR2_Text_Markdown-0.1.0/
- doc/
- pear2.php.net/
- PEAR2_Text_Markdown/
- examples/
- examples/
- examples/
- PEAR2_Text_Markdown/
- pear2.php.net/
- php/
- PEAR2/
- Autoload.php
- Exception.php
- MultiErrors/
- MultiErrors.php
- Text/
- Markdown/
- Apidoc/
- Apidoc.php
- Extra/
- Extra.php
- Main.php
- Plugin/
- Plugin.php
- Wiki/
- Wiki.php
- Markdown/
- PEAR2/
- doc/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
*
* Span plugin for Markdown anchor shortcuts.
*
* You can link to another page using `[display text](http://example.com)`.
*
* Alternatively, you can use defined links ...
*
* Show [this link][id].
*
* [id]: http://example.com
*
* And a shorthand for defined links ...
*
* Show the [example][].
*
* [example]: http://example.com
*
* Named-reference link definitions are captured in the prepare() phase
* by the StripLinkDefs plugin, and are used by both the Link plugin and
* the Image plugin.
*
* @category Solar
*
* @package Markdown_Apidoc
*
* @author Paul M. Jones <pmjones@solarphp.com>
*
* @license http://opensource.org/licenses/bsd-license.php BSD
*
* @version $Id: Link.php 4600 2010-06-16 03:27:55Z pmjones $
*
*/
namespace PEAR2\Text;
class Markdown_Apidoc_Link extends Markdown_Plugin_Link
{
/**
*
* Support callback for named-reference links.
*
* @param string $matches Matches from preg_replace_callback().
*
* @return string The replacement text.
*
*/
protected function _parseReference($matches)
{
$whole_match = $matches[1];
$alt_text = $matches[2];
$name = strtolower(trim($matches[3]));
if (empty($name)) {
// for shortcut links like [this][].
$name = strtolower($alt_text);
}
$link = $this->_markdown->getLink($name);
if ($link) {
$href = $this->_escape($link['href']);
$result = "<link xlink:href=\"$href\"";
if ($link['title']) {
$title = $this->_escape($link['title']);
$result .= " xlink:title=\"$title\"";
}
$result .= ">" . $this->_escape($alt_text) . "</link>";
// encode special Markdown characters
$result = $this->_encode($result);
} else {
$result = $whole_match;
}
return $this->_toHtmlToken($result);
}
/**
*
* Support callback for inline links.
*
* @param string $matches Matches from preg_replace_callback().
*
* @return string The replacement text.
*
*/
protected function _parseInline($matches)
{
$alt_text = $this->_escape($matches[2]);
$href = $this->_escape($matches[3]);
$result = "<link xlink:href=\"$href\"";
if (! empty($matches[6])) {
$title = $this->_escape($matches[6]);
$result .= " xlink:title=\"$title\"";
}
$result .= ">$alt_text</link>";
// encode special Markdown characters
$result = $this->_encode($result);
return $this->_toHtmlToken($result);
}
}
EOF
