Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
6b603c06
Commit
6b603c06
authored
Feb 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added anchors to ApiMarkdown
fixes #2220
parent
149acbf0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
url.md
docs/guide/url.md
+1
-1
ApiMarkdown.php
extensions/apidoc/helpers/ApiMarkdown.php
+14
-1
main.php
extensions/apidoc/templates/bootstrap/layouts/main.php
+11
-0
No files found.
docs/guide/url.md
View file @
6b603c06
...
...
@@ -240,7 +240,7 @@ the above car dealer website as an example, we may declare the following URL rul
// ...
[
'class'
=>
'app\components\CarUrlRule'
,
'connectionID'
=>
'db'
,
...
],
[
'class'
=>
'app\components\CarUrlRule'
,
'connectionID'
=>
'db'
,
/* ... */
],
],
],
],
...
...
extensions/apidoc/helpers/ApiMarkdown.php
View file @
6b603c06
...
...
@@ -12,6 +12,7 @@ use phpDocumentor\Reflection\DocBlock\Type\Collection;
use
yii\apidoc\models\MethodDoc
;
use
yii\apidoc\models\TypeDoc
;
use
yii\apidoc\templates\BaseRenderer
;
use
yii\helpers\Inflector
;
use
yii\helpers\Markdown
;
/**
...
...
@@ -100,7 +101,7 @@ class ApiMarkdown extends GithubMarkdown
// TODO improve code highlighting
if
(
strncmp
(
$code
,
'<?php'
,
5
)
===
0
)
{
$text
=
highlight_string
(
trim
(
$code
),
true
);
$text
=
@
highlight_string
(
trim
(
$code
),
true
);
}
else
{
$text
=
highlight_string
(
"<?php "
.
trim
(
$code
),
true
);
$text
=
str_replace
(
'<?php'
,
''
,
$text
);
...
...
@@ -201,6 +202,18 @@ class ApiMarkdown extends GithubMarkdown
}
/**
* @inheritDocs
*/
protected
function
renderHeadline
(
$block
)
{
$content
=
$this
->
parseInline
(
$block
[
'content'
]);
$hash
=
Inflector
::
slug
(
strip_tags
(
$content
));
$hashLink
=
"<a href=
\"
#
$hash
\"
name=
\"
$hash
\"
>¶</a>"
;
$tag
=
'h'
.
$block
[
'level'
];
return
"<
$tag
>
$content
$hashLink
</
$tag
>"
;
}
/**
* Converts markdown into HTML
*
* @param string $content
...
...
extensions/apidoc/templates/bootstrap/layouts/main.php
View file @
6b603c06
...
...
@@ -9,6 +9,17 @@ use yii\helpers\Html;
\yii\apidoc\templates\bootstrap\assets\AssetBundle
::
register
(
$this
);
// Navbar hides initial content when jumping to in-page anchor
// https://github.com/twbs/bootstrap/issues/1768
$this
->
registerJs
(
<<<JS
var shiftWindow = function() { scrollBy(0, -50) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
JS
,
\yii\web\View
::
POS_HEAD
);
$this
->
beginPage
();
?>
<!DOCTYPE html>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment