Diffs
HatenaSyntax/trunk/test/RelativeLink.php
@@ -0,0 +1,12 @@
+<?php
+include_once dirname(__FILE__) . '/t/t.php';
+
+$lime = new lime_test;
+$parser = HatenaSyntax_Locator::it()->link;
+
+//--
+
+$context = PEG::context('[[keyword]]');
+$result = $parser->parse($context);
+$lime->is($result->getType(), 'relativelink');
+$lime->is($result->getData(), 'keyword');
\ ファイルの末尾に改行がありません
HatenaSyntax/trunk/sample/sample1.php
@@ -17,6 +17,7 @@
-list6
paragraph((footnote))
+[[relativelink]]
|*table header |*table header2 |
|apple |1 |
@@ -81,6 +82,7 @@
</ul>
<p>paragraph(<a href="#hoge_footnote_1" name="hoge_1" title="footnote">*1</a>)</p>
+ <p><a href="relativelink">relativelink</a>"</p>
<table>
<tr>
@@ -100,7 +102,9 @@
<pre>
hoge
fuga</pre>
- <br>
+
+ <p><a href="http://example.com/example.gif"><img src="http://example.com/example.gif" /></a></p>
+
<blockquote>
<h5>blockquote header</h5>
<p>fuga</p>
HatenaSyntax/trunk/code/HatenaSyntax/Locator.php
@@ -96,9 +96,17 @@
return $this->factory->createNodeCreater('imagelink', $parser);
}
+ protected function createRelativeLink()
+ {
+ $body = PEG::join(PEG::many1(PEG::subtract(PEG::anything(), PEG::newLine(), ']]')));
+ $parser = PEG::pack('[', $body, ']');
+
+ return $this->factory->createNodeCreater('relativelink', $parser);
+ }
+
protected function createLink()
{
- return PEG::pack('[', PEG::choice($this->imageLink, $this->httpLink), ']');
+ return PEG::pack('[', PEG::choice($this->relativeLink, $this->imageLink, $this->httpLink), ']');
}
protected function createDefinition()
HatenaSyntax/trunk/code/HatenaSyntax/Renderer.php
@@ -70,7 +70,7 @@
{
foreach ($data as &$elt)
$elt = !$elt instanceof HatenaSyntax_Node ? ($this->config['htmlescape'] ? $this->escape($elt) : $elt)
- : $this->renderNode($elt);
+ : $this->renderNode($elt);
return join('', $data);
}
@@ -104,6 +104,12 @@
return '<a href="' . $url . '"><img src="' . $url . '" /></a>';
}
+ protected function renderRelativeLink($path)
+ {
+ $path = self::escape($path);
+ return '<a href="' . $path . '">' . $path . '</a>';
+ }
+
protected function renderDefinitionList(Array $data)
{
foreach ($data as &$elt) $elt = $this->renderDefinition($elt);