Skip to content

Commit 2c7239f

Browse files
committed
Added permalink icons.
1 parent 857a799 commit 2c7239f

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

css/styles.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ A.anchor{
9494
visibility: hidden;
9595
}
9696

97+
H1,H2,H3,H4,H5{
98+
margin-left: -1.2rem;
99+
}
100+
H1:hover .permalink > SPAN,
101+
H2:hover .permalink > SPAN,
102+
H3:hover .permalink > SPAN,
103+
H4:hover .permalink > SPAN,
104+
H5:hover .permalink > SPAN{
105+
visibility: visible;
106+
}
107+
A.permalink{
108+
float: left;
109+
text-decoration: none;
110+
margin-right: 0.2rem;
111+
}
112+
113+
A.permalink > SPAN{
114+
visibility: hidden;
115+
}
116+
97117

98118
PRE CODE{color: #465760;}
99119
PRE .kw1 {color: #E06645; }

src/DocHeader.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,31 @@ public function getLevel(): int
5555
return $this->level;
5656
}
5757

58-
public function replace(string $subject) : string
58+
/**
59+
* Replaces the <hx> tag in the subject string with the adjusted
60+
* markup for the permalink icon and jump anchor.
61+
*
62+
* @param string $subject
63+
* @param DocFile $file
64+
* @return string
65+
*/
66+
public function replace(string $subject, DocFile $file) : string
5967
{
68+
$template =
69+
'<h%1$s>'.
70+
'<a class="permalink" href="?doc=%3$s#%2$s">'.
71+
'<span>§</span>'.
72+
'</a>'.
73+
'<a class="anchor" id="%2$s"></a>';
74+
6075
$new = str_replace(
6176
sprintf('<h%s>', $this->level),
62-
sprintf('<h%s><a class="anchor" id="%s"></a>', $this->level, $this->id),
77+
sprintf(
78+
$template,
79+
$this->level,
80+
$this->id,
81+
$file->getID()
82+
),
6383
$this->tag
6484
);
6585

0 commit comments

Comments
 (0)