Browse Source

Markdown titles get function improved

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

17
lib/DirScanner.php

@ -562,9 +562,20 @@ Class DirScanner {
if (empty($this->scanResults[$id])) {return [];} if (empty($this->scanResults[$id])) {return [];}
$file = $this->scanResults[$id]; $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 = []; $titles = [];
$content = file_get_contents($file['realpath']); if (!empty($lines)) {
preg_match_all('/#(.+)/u', $content, $matches); foreach($lines as $line) {
preg_match_all('/^#(.+)/u', $line, $matches);
if (!empty($matches[1])) { if (!empty($matches[1])) {
foreach($matches[1] as $title) { foreach($matches[1] as $title) {
$num = substr_count($title, '#'); $num = substr_count($title, '#');
@ -574,6 +585,8 @@ Class DirScanner {
]; ];
} }
} }
}
}
return $titles; return $titles;
} }

1
www/content/Nginx.conf.md

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

5
www/css/manual.css

@ -13,7 +13,8 @@
.indexes h6{font-size:0.8em} .indexes h6{font-size:0.8em}
.indexes a{background-color:transparent;color:#0969da;text-decoration:none} .indexes a{background-color:transparent;color:#0969da;text-decoration:none}
@media (max-width: 640px) { @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{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;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}
.content{margin-left:0;} .content{margin-left:0;}
.content h1{display:none}
} }
Loading…
Cancel
Save