Ejemplo n.º 1
0
def test_sanitize_markdown():
    s = sanitize_markdown('[link](http://believe.in)')
    assert s == '\[link\]\(http://believe.in\)'

    s = sanitize_markdown('>some quote')
    assert s == '>some quote'

    s = sanitize_markdown('*bold*')
    assert s == '\*bold\*'

    s = sanitize_markdown('_bold_')
    assert s == '\_bold\_'

    s = sanitize_markdown('first, second and third')
    assert s == 'first, second and third'
Ejemplo n.º 2
0
def test_sanitize_markdown():
    s = sanitize_markdown('[link](http://believe.in)')
    assert s == '\[link\]\(http://believe.in\)'

    s = sanitize_markdown('>some quote')
    assert s == '>some quote'

    s = sanitize_markdown('*bold*')
    assert s == '\*bold\*'

    s = sanitize_markdown('_bold_')
    assert s == '\_bold\_'

    s = sanitize_markdown('first, second and third')
    assert s == 'first, second and third'
Ejemplo n.º 3
0
    def __init__(self, **kw):
        self.entities = {
            'hashtags': [],
            'symbols': [],
            'user_mentions': [],
            'urls': [],
        }

        for key, val in kw.items():
            setattr(self, key, val)

        if 'text' in kw:
            self.text = sanitize_markdown(kw['text'])

            for word in kw['text'].split(' '):
                if word.startswith(('#', '\#')):
                    tag = word.split('#', 1)[-1]
                    self.entities['hashtags'].append({'text': tag})

                elif word.startswith(('@', '\@')):
                    name = word.split('@', 1)[-1]
                    self.entities['user_mentions'].append({'screen_name': name})

                elif word.startswith('http'):
                    self.entities['urls'].append({
                        'url': word,
                        'expanded_url': 'https://github.com/buttscicles/TweetPoster'
                    })
Ejemplo n.º 4
0
    def __init__(self, **kw):
        self.entities = {
            'hashtags': [],
            'symbols': [],
            'user_mentions': [],
            'urls': [],
        }

        for key, val in kw.items():
            setattr(self, key, val)

        if 'text' in kw:
            self.text = sanitize_markdown(kw['text'])

            for word in kw['text'].split(' '):
                if word.startswith(('#', '\#')):
                    tag = word.split('#', 1)[-1]
                    self.entities['hashtags'].append({'text': tag})

                elif word.startswith(('@', '\@')):
                    name = word.split('@', 1)[-1]
                    self.entities['user_mentions'].append(
                        {'screen_name': name})

                elif word.startswith('http'):
                    self.entities['urls'].append({
                        'url':
                        word,
                        'expanded_url':
                        'https://github.com/buttscicles/TweetPoster'
                    })