Exemplo n.º 1
0
    def __convertFile(self, f, fdestination):
        htmlfile=open(f)
        htmlfile.seek(0)
        html=htmlfile.read()
        htmlfile.close()

        title=self.__getHTMLTitle(html)

        fdestination=os.path.dirname(fdestination)
        fdestination=os.path.join(fdestination, title)
        fdestination=self.__matchNormalizedString(fdestination, 1)

        print 'Converting HTML %s, Content size: %s' % (fdestination, len(html))

        html=self.__cleanLinks(html)

        result=html2textile(html)
        
        fdestination=self.__getUniqueFileName(fdestination)

        newFile=open(fdestination, 'w')
        newFile.write(result.encode('UTF-8'))
        newFile.close()

        self.__flagLink(f, fdestination)
Exemplo n.º 2
0
    def __convertFile(self, f, fdestination):
        htmlfile = open(f)
        htmlfile.seek(0)
        html = htmlfile.read()
        htmlfile.close()

        title = self.__getHTMLTitle(html)

        fdestination = os.path.dirname(fdestination)
        fdestination = os.path.join(fdestination, title)
        fdestination = self.__matchNormalizedString(fdestination, 1)

        print 'Converting HTML %s, Content size: %s' % (fdestination,
                                                        len(html))

        html = self.__cleanLinks(html)

        result = html2textile(html)

        fdestination = self.__getUniqueFileName(fdestination)

        newFile = open(fdestination, 'w')
        newFile.write(result.encode('UTF-8'))
        newFile.close()

        self.__flagLink(f, fdestination)
Exemplo n.º 3
0
def act(controller, bundle, options):
    '''
    Required action method
    '''
    
    context = cp.get_context(controller)
    
    from_lang = cp.get_option(options, 'from', 'markdown').lower()
    to_lang = cp.get_option(options, 'to', 'html').lower()
    
    selection, range = cp.selection_and_range(context)
    
    # grab the whole document if they haven't selected anything...
    if range.length == 0:
        selection = context.string()
        range = cp.new_range(0, len(selection))
    
    # what are we coming from?
    if from_lang == 'markdown':
        html = markdown(selection)
    elif from_lang == 'textile':
        html = textile(selection)
    elif from_lang == 'rest':
        html = rest2html(selection)
    elif from_lang == 'html':
    	html = selection
    else:
    	return
    
    # what are we going to?
    if to_lang == 'markdown':
    	text = html2text(html)
    elif to_lang == 'textile':
    	text = html2textile(html)
    elif to_lang == 'rest':
        text = html2rest(html)
    elif to_lang == 'html':
    	text = html
    else:
    	return
    
    cp.insert_text(context, text, range)
Exemplo n.º 4
0
Arquivo: test.py Projeto: granin/bin
    <p></code><br />
</pre></p>

    <p>This isn&#8217;t code.</p>

    <p>So you see, my friends:</p>

    <ul>
        <li>The time is now</li>
        <li>The time is not later</li>
        <li>The time is not yesterday</li>
        <li>We must act</li>
    </ul>"""

print html2textile(html)
#result
r = """
h2{color:green}. This is a title

h3. This is a subhead

p{color:red}. This is some text of dubious character. Isn’t the use of“quotes”just lazy writing—and theft of‘intellectual property’besides? I think the time has come to see a block quote.

bq[fr]. 
p[fr]. This is a block quote. I’ll admit it’s not the most exciting block quote ever devised.

Simple list:

# one
# two