Fake line numbers, ugh.

master
Nick Sergeant 2012-07-23 10:43:19 -04:00
parent 9f0abed499
commit e1f7477d25
2 changed files with 28 additions and 1 deletions

View File

@ -19,7 +19,26 @@
{{ snipt.stylized|safe }}
</div>
{% else %}
{{ snipt.stylized|safe }}
{% if 'linenos' not in snipt.stylized %}
<table class="highlighttable fakenos">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre>
{% generate_line_numbers for snipt.line_count %}
</pre>
</div>
</td>
<td class="code">
{{ snipt.stylized|safe }}
</td>
</tr>
</tbody>
</table>
{% else %}
{{ snipt.stylized|safe }}
{% endif %}
{% endif %}
{% if snipt.line_count > 8 and not detail and 'snipt-expand' not in snipt.tags_list %}
<a href="#" class="expand">

View File

@ -47,6 +47,14 @@ def get_lexers(context, asvar):
context[asvar] = get_lexers_list()
return ''
@tag(register, [Constant('for'), Variable()])
def generate_line_numbers(context, line_numbers):
html = ''
for i in range(1, line_numbers + 1):
html = html + '<span class="special">{}</span>'.format(i)
return html
@register.filter
def md5(string):