Example #1
0
    def buffer2note(self, note, buflines):
        """ return note that set title, tags, content from buftext """
        pref = EvervimPref.getInstance()
        if pref.usemarkdown == '0':
            note.title = buflines[0]
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + "\n".join(buflines[2:]) + EvernoteAPI.NOTECONTENT_FOOTER
        else:
            note.title = re.sub(r'^#', '',buflines[0]).strip()
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            parsedContent = markdownAndENML.parseMarkdown("\n".join(buflines[2:]))

            contents = buflines[2:]
            encoded_contents = base64.b64encode("\n".join(contents))
            parsedContent = markdownAndENML.parseMarkdown("\n".join(contents))
            parsedContent += ('\n<div style="display: none;">' + encoded_contents + '</div>')

            with open(os.path.dirname(__file__) + '/../../css/default.css', "r") as f:
                css = f.read()
            parsedContent = emailipy.inline_css(parsedContent, css)

            """ html tag and class attribute is not permitted in ENML """
            parsedContent = re.sub('</?html[^>]*>', '', parsedContent)
            parsedContent = re.sub('class="[^"]*"', '', parsedContent)

            note.content  = EvernoteAPI.NOTECONTENT_HEADER + parsedContent.encode('utf-8') + EvernoteAPI.NOTECONTENT_FOOTER

        return note
Example #2
0
    def buffer2note(self, note, buflines):
        """ return note that set title, tags, content from buftext """
        pref = EvervimPref.getInstance()
        if pref.usemarkdown == '0':
            note.title = buflines[0]
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + "\n".join(buflines[2:]) + EvernoteAPI.NOTECONTENT_FOOTER
        else:
            note.title = re.sub(r'^#', '',buflines[0]).strip()
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            parsedContent = markdownAndENML.parseMarkdown("\n".join(buflines[2:]))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + parsedContent.encode('utf-8') + EvernoteAPI.NOTECONTENT_FOOTER

        return note
Example #3
0
    def buffer2note(self, note, buflines):
        """ return note that set title, tags, content from buftext """
        pref = EvervimPref.getInstance()
        if pref.usemarkdown == '0':
            note.title = buflines[0]
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + "\n".join(buflines[2:]) + EvernoteAPI.NOTECONTENT_FOOTER
        else:
            note.title = re.sub(r'^#', '',buflines[0]).strip()
            note = self.api.editTag(note, buflines[1].replace('Tags:', ''))
            parsedContent = markdownAndENML.parseMarkdown("\n".join(buflines[2:]))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + parsedContent + EvernoteAPI.NOTECONTENT_FOOTER

        return note
Example #4
0
    def buffer2note(self, note, buflines):
        """ return note that set title, notebook, tags, content from buftext """
        pref = EvervimPref.getInstance()
        if pref.usemarkdown == '0':
            note.title = buflines[0]
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + "\n".join(buflines[3:]) + EvernoteAPI.NOTECONTENT_FOOTER
        else:
            note.title = re.sub(r'^#', '',buflines[0]).strip()
            parsedContent = markdownAndENML.parseMarkdown("\n".join(buflines[3:]))
            note.content  = EvernoteAPI.NOTECONTENT_HEADER + parsedContent.encode('utf-8') + EvernoteAPI.NOTECONTENT_FOOTER

        notebookName = buflines[1].replace('Notebook:', '').strip()
        if notebookName == "" and pref.defaultnotebook is not None:
            notebookName = pref.defaultnotebook

        notebooks = self.api.listNotebooks()
        notebook = next((n for n in notebooks if n.name == notebookName), None)
        if notebook is not None:
            note.notebookGuid = notebook.guid

        note = self.api.editTag(note, buflines[2].replace('Tags:', ''))

        return note