mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
BUGFIX: Fixed incorrectly formed page specific anchor links (fixes #104)
This commit is contained in:
parent
405af6b377
commit
91a0767d53
@ -482,6 +482,9 @@ class DocumentationParser
|
|||||||
$fileBaseLink,
|
$fileBaseLink,
|
||||||
$url
|
$url
|
||||||
);
|
);
|
||||||
|
} else if (preg_match('/^#/', $url)) {
|
||||||
|
// for relative links begining with a hash use the current page link
|
||||||
|
$relativeUrl = Controller::join_links($baselink, $page->getRelativeLink(), $url);
|
||||||
} else {
|
} else {
|
||||||
// Rewrite public URL
|
// Rewrite public URL
|
||||||
if (preg_match('/^\//', $url)) {
|
if (preg_match('/^\//', $url)) {
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
*
|
*
|
||||||
* Automatically adds anchor links to headings that have IDs
|
* Automatically adds anchor links to headings that have IDs
|
||||||
*/
|
*/
|
||||||
var url = window.location.href;
|
var url = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
|
||||||
|
|
||||||
$("#content h1[id], #content h2[id], #content h3[id], #content h4[id], #content h5[id], #content h6[id]").each(function() {
|
$("#content h1[id], #content h2[id], #content h3[id], #content h4[id], #content h5[id], #content h6[id]").each(function() {
|
||||||
var link = '<a class="heading-anchor-link" title="Link to this section" href="'+ url + '#' + $(this).attr('id') + '">¶</a>';
|
var link = '<a class="heading-anchor-link" title="Link to this section" href="'+ url + '#' + $(this).attr('id') + '">¶</a>';
|
||||||
|
@ -197,6 +197,16 @@ HTML;
|
|||||||
$result
|
$result
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertContains(
|
||||||
|
'[link: with anchor](dev/docs/en/documentationparsertest/2.4/test/#anchor)',
|
||||||
|
$result
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertContains(
|
||||||
|
'[link: relative anchor](dev/docs/en/documentationparsertest/2.4/test/#relative-anchor)',
|
||||||
|
$result
|
||||||
|
);
|
||||||
|
|
||||||
$result = DocumentationParser::rewrite_relative_links(
|
$result = DocumentationParser::rewrite_relative_links(
|
||||||
$this->subPage->getMarkdown(),
|
$this->subPage->getMarkdown(),
|
||||||
$this->subPage
|
$this->subPage
|
||||||
|
@ -8,6 +8,7 @@ test
|
|||||||
[link: subfolder page](subfolder/subpage)
|
[link: subfolder page](subfolder/subpage)
|
||||||
[link: with anchor](/test#anchor)
|
[link: with anchor](/test#anchor)
|
||||||
[link: http](http://silverstripe.org)
|
[link: http](http://silverstripe.org)
|
||||||
|
[link: relative anchor](#relative-anchor)
|
||||||
|
|
||||||
`[Title](api:DataObject)`
|
`[Title](api:DataObject)`
|
||||||
`[Title](api:DataObject::$defaults)`
|
`[Title](api:DataObject::$defaults)`
|
||||||
|
Loading…
Reference in New Issue
Block a user