Fixed interdocumentation linking feature
This commit is contained in:
parent
d8525ca07b
commit
8ff1c4cb20
@ -32,8 +32,11 @@ class Text_Wiki_Parse_Doclink extends Text_Wiki_Parse {
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$options['text'] = $matches[2];
|
||||
$options['text'] = str_replace(':index', $section->getIndex(), $options['text']);
|
||||
$options['text'] = str_replace(':name', $section->getName(), $options['text']);
|
||||
$options['text'] = str_replace(':fullname', $section->getName(true), $options['text']);
|
||||
} else {
|
||||
$options['text'] = $section->getIndex() . ' ' . $section->getName(true);
|
||||
$options['text'] = $section->getIndex();
|
||||
}
|
||||
|
||||
return $this->wiki->addToken($this->rule, $options);
|
||||
|
8
manual/new/lib/Text/Wiki/Render/Latex/Doclink.php
Normal file
8
manual/new/lib/Text/Wiki/Render/Latex/Doclink.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class Text_Wiki_Render_Latex_Doclink extends Text_Wiki_Render {
|
||||
|
||||
function token($options)
|
||||
{
|
||||
return '\ref{' . $options['path'] . '}';
|
||||
}
|
||||
}
|
@ -4,12 +4,19 @@ class Text_Wiki_Render_Latex_Heading extends Text_Wiki_Render {
|
||||
|
||||
function token($options)
|
||||
{
|
||||
static $label = array();
|
||||
|
||||
// get nice variable names (type, level)
|
||||
extract($options);
|
||||
|
||||
if ($type == 'start') {
|
||||
switch ($level)
|
||||
{
|
||||
|
||||
while (count($label) >= $level) {
|
||||
array_pop($label);
|
||||
}
|
||||
$label[] = Sensei_Doc_Section::convertNameToPath($text);
|
||||
|
||||
switch ($level) {
|
||||
case '1':
|
||||
return '\chapter{';
|
||||
case '2':
|
||||
@ -22,12 +29,13 @@ class Text_Wiki_Render_Latex_Heading extends Text_Wiki_Render {
|
||||
return '\paragraph{';
|
||||
case '6':
|
||||
return '\subparagraph{';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($type == 'end') {
|
||||
return "}\n";
|
||||
return "}\n\label{" . implode(':', $label) . "}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
17
vendor/Sensei/Sensei/Doc/Renderer/Xhtml.php
vendored
17
vendor/Sensei/Sensei/Doc/Renderer/Xhtml.php
vendored
@ -187,12 +187,17 @@ class Sensei_Doc_Renderer_Xhtml extends Sensei_Doc_Renderer
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function makeUrl(Sensei_Doc_Section $section)
|
||||
public function makeUrl($section)
|
||||
{
|
||||
if ($section instanceof Sensei_Doc_Section) {
|
||||
$path = $section->getPath();
|
||||
} else {
|
||||
$path = $section;
|
||||
}
|
||||
|
||||
$url = $this->_options['url_prefix'];
|
||||
|
||||
if ($this->_options['section'] instanceof Sensei_Doc_Section) {
|
||||
$path = $section->getPath();
|
||||
$level = $this->_options['section']->getLevel();
|
||||
$url .= implode(':', array_slice(explode(':', $path), 0, $level));
|
||||
}
|
||||
@ -205,9 +210,13 @@ class Sensei_Doc_Renderer_Xhtml extends Sensei_Doc_Renderer
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function makeAnchor(Sensei_Doc_Section $section)
|
||||
public function makeAnchor($section)
|
||||
{
|
||||
$path = $section->getPath();
|
||||
if ($section instanceof Sensei_Doc_Section) {
|
||||
$path = $section->getPath();
|
||||
} else {
|
||||
$path = $section;
|
||||
}
|
||||
|
||||
if ($this->_options['section'] instanceof Sensei_Doc_Section) {
|
||||
$level = $this->_options['section']->getLevel();
|
||||
|
26
vendor/Sensei/Sensei/Doc/Section.php
vendored
26
vendor/Sensei/Sensei/Doc/Section.php
vendored
@ -114,9 +114,9 @@ class Sensei_Doc_Section implements Countable
|
||||
public function getIndex($separator = '.')
|
||||
{
|
||||
if ($this->_parent->_name !== null) {
|
||||
return $this->_parent->getIndex($separator) . ($this->_index + 1) . $separator;
|
||||
return $this->_parent->getIndex($separator) . $separator . ($this->_index + 1);
|
||||
} else {
|
||||
return ($this->_index + 1) . $separator;
|
||||
return ($this->_index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ class Sensei_Doc_Section implements Countable
|
||||
|
||||
$path = preg_replace($patterns, $replacements, strtolower($this->_name));
|
||||
|
||||
return $path;
|
||||
return self::convertNameToPath($this->_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,4 +385,22 @@ class Sensei_Doc_Section implements Countable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts section name to section path.
|
||||
*
|
||||
* Section path is generated from section name by making section name
|
||||
* lowercase, replacing all whitespace with a dash and removing all
|
||||
* characters that are not a letter, a number or a dash.
|
||||
*
|
||||
* @param $name string section name
|
||||
* @return section path
|
||||
*/
|
||||
public static function convertNameToPath($name)
|
||||
{
|
||||
$patterns = array('/\s/', '/[^a-z0-9-]/');
|
||||
$replacements = array('-', '');
|
||||
|
||||
return preg_replace($patterns, $replacements, strtolower($name));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user