Man Page Reformatted on Mobile (and Desktop)


 
Thread Tools Search this Thread
The Lounge What is on Your Mind? Man Page Reformatted on Mobile (and Desktop)
# 1  
Old 09-29-2018
Man Page Reformatted on Mobile (and Desktop)

After experimenting with various Linux utilities like man2html and mandocs and other formats and software, none of them worked as well (or as clear) as by formatting by using PHP preg_replace() to add some CSS elements (wrappers) and then using the <pre> element combined with using jQuery to further refine.

So, today, I have redone all the individual man pages on mobile (and touched up the desktop man pages) with simple PHP code like this:

Code:
if($_COOKIE['neostyle'] == 'mobile') 
   { 
      putenv("MANWIDTH=50"); 
   } 
   else 
   { 
     putenv("MANWIDTH=120"); 
   }

and some simple formatting regex in PHP:

Code:
function addclasstoallCaps ($in) 
{ 
$out = preg_replace('/(<b>([A-Z\s]*)<\/b>)/','<div class="neo-man-caps">\\1</div>', $in); 
return $out; 
}

and some more CSS for mobile:

Code:
<style>
pre {
    margin: 2px;
    padding: 15px;
    border: 1px solid;
    margin-right: 10px;
    border-style: solid;
    border-color: rgba(0, 0, 0, .2);
    background-color: rgba(7, 27, 183, .05);
    overflow: auto;
    font-size: 16px;
    line-height: 20px;
    /*   width=100%; */
}
</style>

combined with some quick and easy jQuery:

Code:
<script>
$(function(){
 $('.neo-man-caps, .neo-man-header').css({"color":"midnightblue"});
 $('.neo-mobile-man').find('i').css({"color":"purple"});
 $('#neo-man-h1-bits, #neo-man-h1bits-section, h1').css({"font-size":"1em"});
 $('#neo-man-h1-bits, #neo-man-h1bits-section, h1, .neo-man-banner').css({"color":"palegreen","background-color":"black"});
 $('h1').find('a').css({"color":"palegreen","background-color":"black"});
});
</script>

So, things are looking much better for all man pages on mobile and the desktop man pages are a bit crisper.

Not as perfect as I would like it, but much better, especially on mobile (desktop was already very good).

Cheers.
These 3 Users Gave Thanks to Neo For This Post:
# 2  
Old 09-30-2018
This messy, but effective, addlinks() PHP function I wrote many years ago for the man pages has been working well over the years and continues to work well today. The only recent change is to add class="neo-man-link" to the links:

Code:
function addlinks($output,$os,$section='',$origin=''){
    global $vbulletin, $col2_f;
    $style = ' style="font-size:1.2em;" class="neo-man-link" ';
    if($_GET['apropos'] == '1' && $col2_f == '2')
    {
      define('REGEX7',"/(\w[-\:.\+\w]*)\s*\((\d)?(\w+)?\)/");
      $rep_string="<a $style href=\"/man-page/$os/$2$3/$1/\">$1($2$3)</a>";
    }
    elseif($_GET['apropos'] == '1' && $col2_f == '1')
    {
      define('REGEX7',"/(\w[\-\:.\+\w]*)\s*\(([0-9])\)/");
      $rep_string="<a $style href=\"/man-page/$os/$2/$1/\">$1($2)</a>";
      $set2=TRUE;
    }
    else
    {
      define('REGEX7',"/(\w[-\:.\+\w]*)\s*\((\d)(\w+)?\)/");
      $rep_string="<a $style href=\"/man-page/$os/$2$3/$1/\">$1($2$3)</a>";
    }

    if ($_GET['apropos'] == '1'){

            if($set2)
             {
              $save = $output;
              $out =preg_replace(REGEX7, $rep_string, $output);
              if(preg_match('/\d/',$output))
                  $output = strtolower($out);
              else
                  $output = $save;
             }
            else
              {
              $output =preg_replace(REGEX7, $rep_string, $output);
              }
            $output = trim($output);
     }
    else {
            if (preg_match("/(\w[\-\:\.\w]*)\((\d)(\w+)\)/",$output))
            {
                 $output=preg_replace(REGEX7, $rep_string, $output);
            }
            else 
            {
               $output=preg_replace("/(\w[\-\:\.\w]*)\((\d)\)/",
               "<a $style href=\"/man-page/$os/\\2/\\1/\">\\1(\\2)</a>",$output);
            }
        }
    $output=ltrim($output);
    return $output;
}

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Reformatted Advanced UNIX.COM Search Page (Desktop)

Just enabled Bootstrap for the advanced forum search page (desktop view): https://www.unix.com/search.php That' page still needs work, and to be converted from <table> elements to <div> elements, and to be redesigned, but in the meantime, it's OK using Bootstrap CSS. Note: Before, we had... (0 Replies)
Discussion started by: Neo
0 Replies

2. Solaris

man page question

What does the last change means in man page .. does that this man page has not been updated since 2003 or something else ? newfs-options The options are documented in the newfs man page. SunOS 5.10 Last change: 9 Dec 2003 1 System... (2 Replies)
Discussion started by: fugitive
2 Replies

3. Solaris

Unable to get help from man page

Help, it seem that i am unable to get man help form solaris 10. I am running SunOS unknown 5.10 Generic_120012-14 i86pc i386 i86pc when ever i try to man a command what i get is "No manual entry" like the one below. # man grep No manual entry for grep. # man ls No manual entry for ls.... (8 Replies)
Discussion started by: ezsurf
8 Replies

4. UNIX for Advanced & Expert Users

man page issue

Man page is not working my system. It is giving the following the following error > man ls gdbm fatal: read error with debug option > man -d ls ... .... ... ... using less as pager checking for locale en_US add_nls_manpath(): processing /usr/local/man:/usr/share/man:/usr/X11R6/man... (4 Replies)
Discussion started by: praveenkumar_l
4 Replies

5. Red Hat

scp-1.2.27 man page

Hi Guys, I'm looking for the man page for scp version 1.2.27 I have an old redhat server that has a few large scripts that use this version and I want to know what the -A flag does and the man page is not on there. (4 Replies)
Discussion started by: Tornado
4 Replies

6. UNIX for Dummies Questions & Answers

adding a man page

I was wonderiong if ther is a way for a user to add a man page specific to thier account. similar to copying the .1 or .1.gz to /usr/share/man/man1 "cp *.1.gz /usr/share/man/man1". Except for using another folder as I don't have access to /usr/share/man/man1. I would think that this might involve... (1 Reply)
Discussion started by: jacob358
1 Replies

7. UNIX for Dummies Questions & Answers

how do you create a man page?

i've never done this before. i created a script that I placed in /usr/bin, but want to create a man page for it. i'm clueless thanks (3 Replies)
Discussion started by: theDirtiest
3 Replies
Login or Register to Ask a Question