code4Py | Style Unified Differences

As per recently created page, the following diff command output representing unified differences, needed to be styled;

[vagrant@localhost python]$ diff -u A B
--- A   2014-08-20 20:13:30.315009258 +0000
+++ B   2014-08-20 20:13:39.021009349 +0000
@@ -1,6 +1,9 @@
+typeset -i sum=0
 while read num
   printf "%d " ${num}
+  sum=sum+${num}
 done <<EOF
@@ -9,5 +12,4 @@

+echo; echo "Sum: ${sum}"
[vagrant@localhost python]$

Source Code (GitHub Gist)
I have completed writing python script that will generate HTML output as follows.

    <span style='color: green'>typeset -i sum=0</span><br />
    <span style='color: green'></span><br />
    while read num<br />
    do<br />
      printf "%d " ${num}<br />
    <span style='color: green'>  sum=sum+${num}</span><br />
    done <<EOF<br />
    1<br />
    5<br />
    EOF<br />
    <br />
    <span style='color: red'>echo </span><br />
    <span style='color: red'></span><br />
    <span style='color: green'>echo; echo "Sum: ${sum}"</span>

Style Output
This output tabulates the differences in N-row(s) and single-column format, if properly embedded into table element of HTML document, which could then be rendered by web browser based on CSS properties (if defined).


One thought on “code4Py | Style Unified Differences

  1. Pingback: taT4Py | Recursively Search Regex Patterns | PrayogShala

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s