summaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
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;