Skip to content

Commit ce9781d

Browse files
committed
Merge branch 'legacy/0.9'
Conflicts: CHANGES.rst isso/core.py isso/dispatch.py setup.py
2 parents d386590 + b59f650 commit ce9781d

17 files changed

+133
-28
lines changed

CHANGES.rst

+20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ Changelog for Isso
77
- Nothing changed yet.
88

99

10+
0.9.3 (2014-07-09)
11+
------------------
12+
13+
- remove scrollIntoView while expanding further comments if a fragment is used
14+
(e.g. #isso-thread brought you back to the top, unexpectedly)
15+
16+
- implement a custom Markdown renderer to support multi-line code listings. The
17+
extension "fenced_code" is now enabled by default and generates HTML
18+
compatible with Highlight.js__.
19+
20+
- escape HTML entities when editing a comment with raw HTML
21+
22+
- fix CSS for input
23+
24+
- remove isso.css from binary distribution to avoid confusion (it's still there
25+
from the very first release, but modifications do not work)
26+
27+
.. __: http://highlightjs.org/
28+
29+
1030
0.9 (2014-05-29)
1131
----------------
1232

MANIFEST.in

-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ include isso/js/embed.min.js
77
include isso/js/embed.dev.js
88
include isso/js/count.min.js
99
include isso/js/count.dev.js
10-
11-
include isso/css/isso.css

docs/_static/css/site.scss

+15
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ main {
209209
h4 {
210210
margin-bottom: 0.5em;
211211
}
212+
213+
blockquote {
214+
margin-top: 10px;
215+
margin-bottom: 10px;
216+
padding-left: 15px;
217+
border-left: 3px solid #ccc;
218+
}
219+
220+
pre {
221+
background: #eee;
222+
border: 1px solid #ddd;
223+
padding: 10px 15px;
224+
color: #4d4d4c;
225+
overflow: auto;
226+
}
212227
}
213228

214229
.sidebar {

docs/conf.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,27 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import pkg_resources
16-
dist = pkg_resources.get_distribution("isso")
17-
1815
import sys
16+
import io
17+
import re
18+
import pkg_resources
1919

2020
from os.path import join, dirname
2121
sys.path.insert(0, join(dirname(__file__), "_isso/"))
2222

23+
try:
24+
dist = pkg_resources.get_distribution("isso")
25+
except pkg_resources.DistributionNotFound:
26+
dist = type("I'm a Version", (object, ), {})
27+
with io.open(join(dirname(__file__), "../setup.py")) as fp:
28+
for line in fp:
29+
m = re.match("\s*version='([^']+)'\s*", line)
30+
if m:
31+
dist.version = m.group(1)
32+
break
33+
else:
34+
dist.version = ""
35+
2336
# If extensions (or modules to document with autodoc) are in another directory,
2437
# add these directories to sys.path here. If the directory is relative to the
2538
# documentation root, use os.path.abspath to make it absolute, like shown here.

isso/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#
2626
# Isso – a lightweight Disqus alternative
2727

28-
from __future__ import print_function
28+
from __future__ import print_function, unicode_literals
2929

3030
import pkg_resources
3131
dist = pkg_resources.get_distribution("isso")

isso/css/isso.css

+1-9
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,12 @@
178178
.isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
179179
padding: .3em 10px;
180180
max-width: 100%;
181+
border-radius: 3px;
181182
background-color: #fff;
182183
line-height: 1.4em;
183184
border: 1px solid rgba(0, 0, 0, 0.2);
184185
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
185186
}
186-
.isso-postbox > .form-wrapper > .auth-section .input-wrapper:first-child input {
187-
border-radius: 3px 0 0 3px;
188-
border-right: 0;
189-
}
190-
.isso-postbox > .form-wrapper > .auth-section .input-wrapper:nth-last-child(2) input {
191-
border-radius: 0 3px 3px 0;
192-
border-left: 0;
193-
}
194187
.isso-postbox > .form-wrapper > .auth-section .post-action {
195188
display: inline-block;
196189
float: right;
@@ -220,7 +213,6 @@
220213
}
221214
.isso-postbox > .form-wrapper > .auth-section .input-wrapper input {
222215
width: 100%;
223-
border-radius: 3px;
224216
}
225217
.isso-postbox > .form-wrapper > .auth-section .post-action {
226218
display: block;

isso/dispatch.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- encoding: utf-8 -*-
22

3+
from __future__ import unicode_literals
4+
35
import sys
46
import os
57
import logging

isso/js/app/isso.js

-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
8989
if(rv.hidden_replies > 0) {
9090
insert_loader(rv, lastcreated);
9191
}
92-
93-
if (window.location.hash.length > 0) {
94-
$(window.location.hash).scrollIntoView();
95-
}
9692
},
9793
function(err) {
9894
console.log(err);

isso/js/app/utils.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ define(["app/i18n"], function(i18n) {
3838
i18n.pluralize("date-year", Math.ceil(days / 365.25));
3939
};
4040

41+
var HTMLEntity = {
42+
"&": "&",
43+
"<": "&lt;",
44+
">": "&gt;",
45+
'"': '&quot;',
46+
"'": '&#39;',
47+
"/": '&#x2F;'
48+
};
49+
50+
var escape = function(html) {
51+
return String(html).replace(/[&<>"'\/]/g, function (s) {
52+
return HTMLEntity[s];
53+
});
54+
};
55+
4156
var text = function(html) {
4257
var _ = document.createElement("div");
4358
_.innerHTML = html.replace(/<div><br><\/div>/gi, '<br>')
@@ -47,8 +62,8 @@ define(["app/i18n"], function(i18n) {
4762
};
4863

4964
var detext = function(text) {
50-
return text.replace(/\n\n/gi, '<br><div><br></div>')
51-
.replace(/\n/gi, '<br>');
65+
return escape(text.replace(/\n\n/gi, '<br><div><br></div>')
66+
.replace(/\n/gi, '<br>'));
5267
};
5368

5469
return {

isso/run.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- encoding: utf-8 -*-
22

3+
from __future__ import unicode_literals
4+
35
import os
46

57
from isso import make_app

isso/tests/test_html.py

+32
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
except ImportError:
66
import unittest
77

8+
import textwrap
89

910
from isso import config
1011
from isso.utils import html
@@ -31,6 +32,37 @@ def test_markdown_extensions(self):
3132
for (input, expected) in examples:
3233
self.assertEqual(convert(input), expected)
3334

35+
def test_github_flavoured_markdown(self):
36+
convert = html.Markdown(extensions=("fenced_code", ))
37+
38+
# without lang
39+
_in = textwrap.dedent("""\
40+
Hello, World
41+
42+
```
43+
#!/usr/bin/env python
44+
print("Hello, World")""")
45+
_out = textwrap.dedent("""\
46+
<p>Hello, World</p>
47+
<pre><code>#!/usr/bin/env python
48+
print("Hello, World")
49+
</code></pre>""")
50+
51+
self.assertEqual(convert(_in), _out)
52+
53+
# w/ lang
54+
_in = textwrap.dedent("""\
55+
Hello, World
56+
57+
```python
58+
#!/usr/bin/env python
59+
print("Hello, World")""")
60+
_out = textwrap.dedent("""\
61+
<p>Hello, World</p>
62+
<pre><code class="python">#!/usr/bin/env python
63+
print("Hello, World")
64+
</code></pre>""")
65+
3466
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
3567
def test_sanitizer(self):
3668
sanitizer = html.Sanitizer(elements=[], attributes=[])

isso/utils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- encoding: utf-8 -*-
22

3-
from __future__ import division
3+
from __future__ import division, unicode_literals
44

55
import pkg_resources
66
werkzeug = pkg_resources.get_distribution("werkzeug")

isso/utils/html.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- encoding: utf-8 -*-
22

3+
from __future__ import unicode_literals
4+
35
import pkg_resources
46
import operator
57

@@ -54,16 +56,30 @@ def Markdown(extensions=("strikethrough", "superscript", "autolink")):
5456

5557
flags = reduce(operator.xor, map(
5658
lambda ext: getattr(misaka, 'EXT_' + ext.upper()), extensions), 0)
59+
md = misaka.Markdown(Unofficial(), extensions=flags)
5760

5861
def inner(text):
59-
rv = misaka.html(text, extensions=flags).rstrip("\n")
60-
if not rv.endswith("<p>") and not rv.endswith("</p>"):
61-
return "<p>" + rv + "</p>"
62-
return rv
62+
rv = md.render(text).rstrip("\n")
63+
if rv.startswith("<p>") or rv.endswith("</p>"):
64+
return rv
65+
return "<p>" + rv + "</p>"
6366

6467
return inner
6568

6669

70+
class Unofficial(misaka.HtmlRenderer):
71+
"""A few modifications to process "common" Markdown.
72+
73+
For instance, fenced code blocks (~~~ or ```) are just wrapped in <code>
74+
which does not preserve line breaks. If a language is given, it is added
75+
to <code class="$lang">, compatible with Highlight.js.
76+
"""
77+
78+
def block_code(self, text, lang):
79+
lang = ' class="{0}"'.format(lang) if lang else ''
80+
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
81+
82+
6783
class Markup(object):
6884

6985
def __init__(self, conf):

isso/utils/parse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from __future__ import print_function
2+
from __future__ import print_function, unicode_literals
33

44
from itertools import chain
55

isso/views/comments.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- encoding: utf-8 -*-
22

3+
from __future__ import unicode_literals
4+
35
import re
46
import cgi
57
import time

isso/wsgi.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- encoding: utf-8 -*-
22

3+
from __future__ import unicode_literals
4+
35
import socket
46

57
try:

share/isso.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ reply-to-self = false
134134

135135
# Misaka-specific Markdown extensions, all flags starting with EXT_ can be used
136136
# there, separated by comma.
137-
options = strikethrough, superscript, autolink
137+
options = strikethrough, superscript, autolink, fenced_code
138138

139139
# Additional HTML tags to allow in the generated output, comma-separated. By
140140
# default, only a, blockquote, br, code, del, em, h1, h2, h3, h4, h5, h6, hr,

0 commit comments

Comments
 (0)