Skip to main content

Markdown extension for embedding tweets

Project description

https://badge.fury.io/py/mdx-twitter.png https://travis-ci.org/zen4ever/mdx-twitter.png?branch=master https://pypip.in/d/mdx-twitter/badge.png

Markdown extension for embedding tweets using twitter OEmbed API

How to use

Allows you to embed tweets into your Markdown.

Just install the package:

pip install mdx-twitter

Because Twitter API 1.1 requires you to authenticate, you will need to create a config file with your credentials at ‘~/.mdx_twitter.cfg’:

[Twitter]
CONSUMER_KEY=xxxxxxxxxxxx
CONSUMER_SECRET=xxxxxxxxxxxx
ACCESS_TOKEN=xxxxxxxxxxxx
ACCESS_TOKEN_SECRET=xxxxxxxxxxxx

Then just add ‘twitter’ to the list of your extensions:

import markdown

md = markdown.Markdown(extensions=['twitter'])

Twitter urls in your Makdown will become embedded tweets:

https://twitter.com/jasoncosta/status/240192632003911681

Django integration

Since Twitter has a rate limit on their APIs, and doing network calls all the time just to render Markdown is a bad idea anyways, we would need some caching.

If you are using mdx-twitter in a Django project, it will automatically use your cache settings to cache HTML returned from Twitter API.

Also, you could place your API credentials in TWITTER_SETTINGS variable in your project’s settings.py, instead of using .cfg file

TWITTER_SETTINGS = {
    'CONSUMER_KEY': '',
    'CONSUMER_SECRET': '',
    'ACCESS_TOKEN': '',
    'ACCESS_TOKEN_SECRET': '',
}

History

0.1.0 (2013-08-31)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdx-twitter-0.2.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page