Skip to content

Commit 049f1d2

Browse files
committed
add syntax highlighting to readme
1 parent ab8a12f commit 049f1d2

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

README.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,43 @@ installation
1616
usage
1717
-----
1818

19-
>>> from ttp import ttp
20-
>>> p = ttp.Parser()
21-
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
22-
>>> result.reply
23-
'burnettedmond'
24-
>>> result.users
25-
['burnettedmond']
26-
>>> result.tags
27-
['IvoWertzel']
28-
>>> result.urls
29-
['https://github.com/burnettedmond/']
30-
>>> result.html
31-
u'<a href="http://twitter.com/burnettedmond">@burnettedmond</a>, you now support <a href="https://twitter.com/search?q=%23IvoWertzel">#IvoWertzel</a>\'s tweet parser! <a href="https://github.com/edburnett/">https://github.com/edburnett/</a>'
19+
```python
20+
>>> from ttp import ttp
21+
>>> p = ttp.Parser()
22+
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
23+
>>> result.reply
24+
'burnettedmond'
25+
>>> result.users
26+
['burnettedmond']
27+
>>> result.tags
28+
['IvoWertzel']
29+
>>> result.urls
30+
['https://github.com/burnettedmond/']
31+
>>> result.html
32+
u'<a href="http://twitter.com/burnettedmond">@burnettedmond</a>, you now support <a href="https://twitter.com/search?q=%23IvoWertzel">#IvoWertzel</a>\'s tweet parser! <a href="https://github.com/edburnett/">https://github.com/edburnett/</a>'
33+
```
3234

3335
If you need different HTML output just subclass and override the `format_*` methods.
3436

3537
You can also ask for the span tags to be returned for each entity:
3638

37-
>>> p = ttp.Parser(include_spans=True)
38-
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
39-
>>> result.urls
40-
[('https://github.com/burnettedmond/', (57, 87))]
39+
```python
40+
>>> p = ttp.Parser(include_spans=True)
41+
>>> result = p.parse("@burnettedmond, you now support #IvoWertzel's tweet parser! https://github.com/edburnett/")
42+
>>> result.urls
43+
[('https://github.com/burnettedmond/', (57, 87))]
44+
```
4145

4246

4347
To use the shortlink follower (depends on the [Requests](http://docs.python-requests.org/) library):
4448

45-
>>> from ttp import utils
46-
>>> # assume that result.urls == ['http://t.co/8o0z9BbEMu', u'http://bbc.in/16dClPF']
47-
>>> print utils.follow_shortlinks(result.urls) # pass in list of shortlink URLs
48-
{'http://t.co/8o0z9BbEMu': [u'http://t.co/8o0z9BbEMu', u'http://bbc.in/16dClPF', u'http://www.bbc.co.uk/sport/0/21711199#TWEET650562'], u'http://bbc.in/16dClPF': [u'http://bbc.in/16dClPF', u'http://www.bbc.co.uk/sport/0/21711199#TWEET650562']}
49-
>>> # note that bad shortlink URLs have a key to an empty list (lost/forgotten shortlink URLs don't generate any error)
49+
```python
50+
>>> from ttp import utils
51+
>>> # assume that result.urls == ['http://t.co/8o0z9BbEMu', u'http://bbc.in/16dClPF']
52+
>>> print utils.follow_shortlinks(result.urls) # pass in list of shortlink URLs
53+
{'http://t.co/8o0z9BbEMu': [u'http://t.co/8o0z9BbEMu', u'http://bbc.in/16dClPF', u'http://www.bbc.co.uk/sport/0/21711199#TWEET650562'], u'http://bbc.in/16dClPF': [u'http://bbc.in/16dClPF', u'http://www.bbc.co.uk/sport/0/21711199#TWEET650562']}
54+
>>> # note that bad shortlink URLs have a key to an empty list (lost/forgotten shortlink URLs don't generate any error)
55+
```
5056

5157

5258
changelog

0 commit comments

Comments
 (0)