I have the following data that my Python (Flask) application passes to a Jinja2 template and renders it as HTML:
--- a
+++ b
[
@@ -0 +0 @@
{
u'po': u'04312',
u'storage': [
@@ -2,1 +2,1 @@
@@ -2,1 +2 @@
+{u'type': u'FusionIO', u'capacity': 3000, u'number': 2, u'speed': u'N/A', u'total_capacity': 6000},
],
u'serial': u'YYZ666',
u'added_by': ObjectId('5208f7e054d79f70f9e13f7f'),
u'edited_by': ObjectId('5208f7e054d79f70f9e13f7f'),
-u'revision': 2,
+u'revision': 3,
u'status': u'Prod',
-u'edited_date': datetime.datetime(2013, 8, 19, 21, 40, 30, 275000),
+u'edited_date': datetime.datetime(2013, 8, 20, 13, 34, 25, 621000),
-u'memory': u'256',
+u'memory': u'1024',
u'racked': u'Yes',
@@ @@
},
]
HTML source:
<div class="server-diff">
<h2 class="dashboard-heading">Diff</h2>
<p>--- a
+++ b
[
@@ -0 +0 @@
{
u'po': u'04312',
u'storage': [
@@ -2,1 +2,1 @@
@@ -2,1 +2 @@
+{u'type': u'FusionIO', u'capacity': 3000, u'number': 2, u'speed': u'N/A', u'total_capacity': 6000},
],
u'serial': u'YYZ666',
u'added_by': ObjectId('5208f7e054d79f70f9e13f7f'),
u'edited_by': ObjectId('5208f7e054d79f70f9e13f7f'),
-u'revision': 2,
+u'revision': 3,
u'status': u'Prod',
-u'edited_date': datetime.datetime(2013, 8, 19, 21, 40, 30, 275000),
+u'edited_date': datetime.datetime(2013, 8, 20, 13, 34, 25, 621000),
-u'memory': u'256',
+u'memory': u'1024',
u'racked': u'Yes',
@@ @@
},
]</p>
</div>
I would like to be able to change the text colour of lines that start with + to green and - to red.
I know you can do regexps in javascript so I'm guessing you can do something like getting all the lines in p and then apply a CSS to them but I have no idea how to do that.
How can I do this in javascript (or jquery, which I already use)/css?
Thank you.