Skip to content

Commit

Permalink
Fast Alternation
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Feb 28, 2024
1 parent aa36e00 commit a905cbe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.gitattributes export-ignore
.gitignore export-ignore
README.md export-ignore
package.json export-ignore
test.php export-ignore
test.txt export-ignore
2 changes: 1 addition & 1 deletion about.page
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ icon: 'M12 2A3 3 0 0 0 9 5A3 3 0 0 0 11 7.83V9H8V11H11V19.92C10.26 19.79 9.5 19.
color: '#3c7271'
author: Taufik Nurrohman
type: Markdown
version: 1.0.0
version: 1.0.1
...

This extension automatically generates anchor targets on headings. If you are already using the
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function page__content($content) {
return $content;
}
$count = [];
return \preg_replace_callback('/<(caption|div|dt|figcaption|h[1-6]|p|summary)(\s(?:"[^"]*"|\'[^\']*\'|[^>])*)?>([\s\S]*?)<\/\1>/i', static function ($m) use (&$count) {
return \preg_replace_callback('/<(caption|div|dt|figcaption|h[1-6]|p|summary)(\s(?>"[^"]*"|\'[^\']*\'|[^>])*)?>([\s\S]*?)<\/\1>/i', static function ($m) use (&$count) {
if ('h' === \strtolower($m[1][0]) && \is_numeric(\substr($m[1], 1))) {
if (false !== \stripos($m[2], 'role=') && !\preg_match('/\brole=([\'"]?)heading\1/i', $m[2])) {
return $m[0]; // Skip!
Expand Down

0 comments on commit a905cbe

Please sign in to comment.