summaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
authordweller <dweller@cabin.digital>2024-02-26 14:04:19 +0200
committerdweller <dweller@cabin.digital>2024-02-26 14:04:19 +0200
commit36d138c406e0e8974da979f9af2414b1f99b3131 (patch)
tree0e51773ff838cc182ad0501661ff1330ae8f1246 /search.php
parentc8cef7f8099ef3caa973c4c5ff19b094121a21dc (diff)
attempt to fix mandoc retarded CSS generation
Diffstat (limited to '')
-rw-r--r--search.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/search.php b/search.php
index af2c398..95d8254 100644
--- a/search.php
+++ b/search.php
@@ -69,17 +69,29 @@
if(!empty($section))
$arg_section = "-s ". escapeshellarg($section);
- $res = exec("man -M $manpath -T html -O fragment $arg_section "
+ $res = exec("man -M $manpath -T html -O fragment,toc $arg_section "
. escapeshellarg($query), $lines, $ret);
if($ret === 0)
{
$url = "$root/?query=". urlencode($query) ."&ampsection=1&action=lmmtfy";
+ /* HACK: fucking mandoc just generates tons of useless <br>s that make <code> stuff
+ * look horrible. So I just remove it here.
+ * As you can see, they also decided to pepper the HTML with inline style coz they
+ * just absolutely hate me, so I strip it too.
+ */
+ for($i = 0; $i < count($lines); $i++)
+ {
+ $line = preg_replace('/\<br.\>/i', '', $lines[$i]);
+ $line = preg_replace('/style=".*"/i', '', $line);
+ if(!empty(trim($line))) $lines2[$i] = $line;
+ }
+
echo "<nav id='lmmtfy'><div><div>";
echo " <label for='lmmtfy_url'>LmmtFy URL</label></div>";
echo " <textarea id='lmmtfy_url' wrap='off' rows='1' readonly>".$url."</textarea>";
echo " <button id='lmmtfy_copy' class='jsonly'>Copy</button></div><nav>";
- echo "<article class='manpage'>". implode(PHP_EOL, $lines) ."</article>";
+ echo "<article class='manpage'>". implode(PHP_EOL, $lines2) ."</article>";
echo "<script src='/js/copy.js'></script>";
$found_man = true;