Giter VIP home page Giter VIP logo

dillo-plugin-man's Introduction

Man plugin for Dillo

Shows local manual pages as HTML in Dillo with clickable links to other manual pages. It uses the man(1) program to generate the HTML from the manual pages (with the -T html extension) and sed(1) to manipulate the HTML.

It comes with a CSS style file that improves the display of manual pages and can be modified to change the appearance.

Installation

To install the plugin use:

$ make install

The two files man.filter.dpi and style.css will be copied into ~/.dillo/dpi/man/. Edit style.css as needed.

Usage

The manual pages are accessed by the name of the manual page alone, man:bash, or with the section number in parenthesis to specify the manual section, man:read(3).

Here are some examples to test it from the command line:

$ dillo man:git
$ dillo man:namespaces
$ dillo "man:groff(7)"

dillo-plugin-man's People

Contributors

rodarima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jansucan

dillo-plugin-man's Issues

Stray `$` when assigning variables in `serve_404()`?

The serve_404() reads:

serve_404() {
  printf "<cmd='start_send_page' url='' '>\n"
  printf "Content-type: text/plain\r\n\r\n"
  $manpage="$1"
  $apropos="$2"
  if [ -z "$1" ]; then

Shouldn't the two assignment just read:

  manpage="$1"
  apropos="$2"

?

[PATCH] Loses a few pipes, passes shellcheck

The attached patch …

  • adds SPDX tag SPDX-FileCopyrightText,
  • explicitly disables irrelevant shellcheck checks,
  • loses a few pipes,
  • loses seemingly unnecessay call to sed in favour of ${variable//search/replace}, and
  • double-quotes a few command substitutions, just to be on the safe side.

📎 shellcheck.diff.txt

It passes shellcheck and seems to work just fine here, but somebody should probably check it on their side.


Overview:

diff --git a/man.filter.dpi b/man.filter.dpi
index 5b9adbc..bc0fb3d 100755
--- a/man.filter.dpi
+++ b/man.filter.dpi
@@ -1,13 +1,14 @@
 #!/bin/bash
-# Copyright (c) 2023 Rodrigo Arias Mallo
+# SPDX-FileCopyrightText: Copyright (c) 2023 Rodrigo Arias Mallo
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-IFS= read -d '>' auth # Ignore auth
-IFS= read -d '>' cmd
+# shellcheck disable=SC2034
+IFS= read -rd '>' auth # Ignore auth
+IFS= read -rd '>' cmd
 
 case "$cmd" in
   "<cmd='open_url' url='"*);;
-  *) echo $cmd; exit;;
+  *) echo "$cmd"; exit;;
 esac
 
 url=${cmd#"<cmd='open_url' url='"}
@@ -17,20 +18,20 @@ serve_404() {
   printf "<cmd='start_send_page' url='' '>\n"
   printf "Content-type: text/plain\r\n\r\n"
   manpage="$1"
-  apropos="$2"
-  if [ -z "$1" ]; then
+  test -n "$manpage" || {
     echo "Not found"
     exit 0
-  fi
-  echo "Manual page not found: $1"
-  if [ -n "$apropos" ]; then
+  }
+  apropos="$2"
+  echo "Manual page not found: $manpage"
+  test -n "$apropos" && {
     printf "\nRelated pages:\n"
     man -k "$apropos"
-  fi
+  }
 }
 
 inject_css() {
-  css=$(cat "$(dirname $(readlink -f $0))/style.css" | tr '\n' ' ')
+  css=$(tr '\n' ' ' < "$(dirname "$(readlink -f "$0")")/style.css")
   sed "s_</style>_$css\n</style>_"
 }
 
@@ -54,19 +55,23 @@ serve_manpage() {
   url="$1"
   ref="${url#"man:"}"
   # Reverse open(3) -> 3 open if given
-  manpage=$(echo "$ref" | sed 's/\(.*\)(\(.*\))/\2 \1/')
+  # shellcheck disable=SC2001
+  manpage=$(sed 's/\(.*\)(\(.*\))/\2 \1/' <<< "$ref")
   # If page not found, return 404
-  if [ -z "$manpage" ]; then
+  test -z "$manpage" && {
     serve_404
     exit 0
-  fi
+  }
+  # $manpage may contain both man section and man page
+  # shellcheck disable=SC2086
   if ! man -w $manpage 2>/dev/null; then
-    apropos=$(echo "$ref" | sed 's/(.*)//')
+    apropos="${ref%%(*}"
     serve_404 "$manpage" "$apropos"
   else
     printf "<cmd='start_send_page' url='' '>\n"
     printf "Content-type: text/html\r\n\r\n"
     unset MANROFFOPT
+    # shellcheck disable=SC2086
     man -Thtml $manpage | fix_br | inject_css | link_xrefs 2>&1
   fi
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.