def save(note, data): html = data['html'] if parsers.remove_html(html): path_new = os.path.join(data['new[notebook]'], data['new[title]'] + note.ext) # If the title or notebook has changed, # move the note by updating its path. if note.path.abs != path_new: try: note.move(path_new) except NoteConflictError: # 409 = Conflict return 'Note already exists', 409 html = parsers.rewrite_external_images(html, note) if note.ext == '.md': content = html2md.html_to_markdown(html) note.write(content) note.clean_resources() # Update all connected clients. #self.refresh_clients() return jsonify({'path': note.path.abs}) return 'Success', 200
def save(note, data): html = data['html'] if parsers.remove_html(html): path_new = os.path.join(data['new[notebook]'], data['new[title]'] + note.ext) # If the title or notebook has changed, # move the note by updating its path. if note.path.abs != path_new: try: note.move(path_new) except NoteConflictError: # 409 = Conflict return 'Note already exists', 409 html = parsers.rewrite_external_images(html, note) if note.ext == '.md': content = html2md.html_to_markdown(html) note.write(content) note.clean_resources() # Update all connected clients. #self.refresh_clients() return jsonify({ 'path': note.path.abs }) return 'Success', 200
def plaintext(self): text = u'' if self.ext == '.pdf': text = self.content else: if self.ext == '.html': text = parsers.remove_html(self.content) elif self.ext == '.md': text = parsers.remove_md(self.content) if isinstance(text, str): text = text.decode('utf-8') return text