Browse Source

Markdown titles get function improved

master
filesite 3 years ago
parent
commit
09f76e712f
  1. 31
      lib/DirScanner.php
  2. 1
      www/content/Nginx.conf.md
  3. 5
      www/css/manual.css

31
lib/DirScanner.php

@ -562,16 +562,29 @@ Class DirScanner { @@ -562,16 +562,29 @@ Class DirScanner {
if (empty($this->scanResults[$id])) {return [];}
$file = $this->scanResults[$id];
$content = @file_get_contents($file['realpath']);
if (empty($content)) {return [];}
# standardize line breaks
$content = str_replace(array("\r\n", "\r"), "\n", $content);
# remove surrounding line breaks
$content = trim($content, "\n");
# split text into lines
$lines = explode("\n", $content);
$titles = [];
$content = file_get_contents($file['realpath']);
preg_match_all('/#(.+)/u', $content, $matches);
if (!empty($matches[1])) {
foreach($matches[1] as $title) {
$num = substr_count($title, '#');
$titles[] = [
'name' => trim(str_replace('#', '', $title)),
'heading' => 'h' . ($num+1),
];
if (!empty($lines)) {
foreach($lines as $line) {
preg_match_all('/^#(.+)/u', $line, $matches);
if (!empty($matches[1])) {
foreach($matches[1] as $title) {
$num = substr_count($title, '#');
$titles[] = [
'name' => trim(str_replace('#', '', $title)),
'heading' => 'h' . ($num+1),
];
}
}
}
}

1
www/content/Nginx.conf.md

@ -25,7 +25,6 @@ Nginx config: @@ -25,7 +25,6 @@ Nginx config:
}
# deny all other php
#
location ~ \.php {
deny all;
}

5
www/css/manual.css

@ -13,7 +13,8 @@ @@ -13,7 +13,8 @@
.indexes h6{font-size:0.8em}
.indexes a{background-color:transparent;color:#0969da;text-decoration:none}
@media (max-width: 640px) {
.indexes{position:static;width:auto;padding-bottom:0.5em;margin-bottom:0.5em;border-bottom:1px solid hsla(210,18%,87%,1)}
.indexes h1{display:block;padding-left:0;padding-bottom:0.3em;text-align:center;font-size:2em;border-bottom:1px solid hsla(210,18%,87%,1)}
.indexes{position:static;width:auto;padding-bottom:0.5em;margin-bottom:0.5em}
.indexes h1{display:block;padding-left:0;padding-bottom:0.3em;text-align:center;font-size:2em}
.content{margin-left:0;}
.content h1{display:none}
}
Loading…
Cancel
Save