1
Fork 0

add ansi to html converter client side

This commit is contained in:
Jake Howard 2016-08-27 21:13:07 +01:00
parent 3d98847392
commit cf1bf7d9e2
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 18 additions and 1 deletions

View file

@ -12,6 +12,7 @@
},
"dependencies": {
"animate.css": "=3.5.1",
"ansi_up": "=1.3.0",
"bootstrap-sass": "=3.3.7",
"font-awesome": "=4.6.3",
"jquery": "=2.2.3",

View file

@ -98,4 +98,5 @@ JINJA_FILTERS = {
"datetime": filters.format_datetime,
"category_find": filters.category_find,
"limit": filters.limit,
"ansi2html": filters.ansi2html
}

View file

@ -19,3 +19,7 @@ def limit(line, length):
return " ".join(line.split(" ")[:length]) + '...'
elif isinstance(line, list):
return line[:length]
def ansi2html(content):
return "<pre class='highlight ansi-up'>{0}</pre>".format(content)

View file

@ -1,6 +1,8 @@
import './creative';
import ansi_up from 'ansi_up';
$('.image').each(function () {
$('.image').each(function () { // setup div-image hybrids
const ele = $(this);
if (ele.data('image')) {
ele.css('background-image', 'url(' + ele.data('image') + ')');
@ -8,3 +10,8 @@ $('.image').each(function () {
ele.removeClass('image');
}
});
$('.ansi-up').each(function () {
const ele = $(this);
ele.html(ansi_up.ansi_to_html(ele.html()));
});

View file

@ -83,3 +83,7 @@ p a {
height: 40vh;
}
}
.highlight.ansi-up {
font-weight: 600;
}