Prettyprint - demo1

Ruter i bakgrunnen,tilpasset font og linehøyde. Egen bakgrunn for Python.

CSS, denne siden

/* Pretty printing styles. Used with prettify.js. */
.str { color: #080; }
.kwd { color: #008; font-weight:bold} /*bs bold for keywords*/
.com { color: #800; font-style:italic}/*bs italic for comments*/
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
/*bs adding font,background, lineheight*/
pre.prettyprint { padding: 2px; border: 1px solid #888; background:url(paperbg.gif);
                 font-family:monospace;font-size:11px;line-height:15px }

/*BS change backround for python*/
pre.lang-py{background-color:#FFFFEC}

/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 /*BS removed{ list-style-type: none }*/
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9{} /*BS removed{ background: #eee }*/

@media print {
  .str { color: #060; }
  .kwd { color: #006; font-weight: bold; }
  .com { color: #600; font-style: italic; }
  .typ { color: #404; font-weight: bold; }
  .lit { color: #044; }
  .pun { color: #440; }
  .pln { color: #000; }
  .tag { color: #006; font-weight: bold; }
  .atn { color: #404; }
  .atv { color: #060; }
}

Javascript

// working with DOM
function copyFragment(fromNode,toNode)
{
   while(toNode.hasChildNodes())
      toNode.removeChild(toNode.lastChild);
   
   nod=fromNode.firstChild;
   while(nod!=null)
   {
      nodcopy=nod.cloneNode(true);
      toNode.appendChild(nodcopy);
      nod=nod.nextSibling;
   }
}
function switchElements(elt1ID,elt2ID)
{
     element1=document.getElementById(elt1ID);
     element2=document.getElementById(elt2ID);
     elementtemp=document.getElementById('temp');
     copyFragment(element1,elementtemp);
     copyFragment(element2,element1);
     copyFragment(elementtemp,element2);
}

Python

#! /usr/bin/python
"""
 Reading fields navn and adresse
 and reports the findings
"""
import cgi
form=cgi.FieldStorage()
print 'Content-type: text/html; charset=iso-8859-1\n'
print form
navn=''
adresse=''
try:
   navn=form['navn'].value
except:
   navn='ukjent'
try:
   adresse=form['adresse'].value
except:
   adresse='ukjent'
print "Dette er det jeg fant: Navn: %s, Adresse: %s"%(navn,adresse)

Python med linjenummer

#! /usr/bin/python
"""
 Reading fields navn and adresse
 and reports the findings
"""
import cgi
form=cgi.FieldStorage()
print 'Content-type: text/html; charset=iso-8859-1\n'
print form
navn=''
adresse=''
try:
   navn=form['navn'].value
except:
   navn='ukjent'
try:
   adresse=form['adresse'].value
except:
   adresse='ukjent'
print "Dette er det jeg fant: Navn: %s, Adresse: %s"%(navn,adresse)

CSS

h1{font-size:24px}
/* table set up */
.tab2 table{font: 11px/24px Verdana, Arial, Helvetica, sans-serif;
          border-collapse:collapse; width: 250px; border:2px solid blue}
.tab2 thead {background-color:yellow;}
.tab2 th{padding: 0 0.5em; text-align:left; border-bottom: 1px solid #CCC;}
.tab2 td{border-bottom: 1px solid #CCC; padding: 0 0.5em;}
.tab2 td+td {border-left: 1px solid #CCC; text-align: left;}
.tab2 td:last-child{text-align: right;}
.tab2 tr:last-child{border-bottom:2px solid blue}