Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

from django.utils.html import linebreaks 

from django.utils.html import urlize 

from django.utils.translation import ugettext_lazy as _ 

 

from markupmirror.markup.base import BaseMarkup 

from markupmirror.markup.base import register_markup 

 

 

class PlainTextMarkup(BaseMarkup): 

    """Markup transformer for plain-text content. 

 

    This uses Django's ``urlize`` and ``linebreaks`` utitlies to convert URLs 

    in the text to clickable links and linebreaks to ``<p>`` and ``<br />`` 

    elements respectively. 

 

    """ 

    codemirror_mode = 'text/plain' 

    title = _(u"Plain text") 

 

    def convert(self, markup): 

        return urlize(linebreaks(markup)) 

 

 

register_markup(PlainTextMarkup) 

 

 

__all__ = ('PlainTextMarkup',)