def test_htmlEscape(self): wrapped = Editor.textToENML(content="<what ever>", format="markdown") self.assertEqual( wrapped, """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> <en-note><p><what ever></p> </en-note>""")
def test_not_checklist(self): wrapped = Editor.textToENML(content=" Item head[0]; ", format="markdown") self.assertEqual( wrapped, """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> <en-note><p>Item head[0]; </p> </en-note>""")
def test_parceInput1(self): testData = self.notes._parceInput("title", "test body", "tag1") self.assertTrue(isinstance(testData, dict)) if not isinstance(testData, dict): return self.assertEqual(testData['title'], "title") self.assertEqual(testData['content'], Editor.textToENML("test body")) self.assertEqual(testData["tags"], ["tag1", ])
def test_TODO(self): MD_TODO = "\n* [ ]item 1\n\n* [x]item 2\n\n* [ ]item 3\n\n" HTML_TODO = "<div><en-todo></en-todo>item 1</div><div><en-todo checked=\"true\"></en-todo>item 2</div><div><en-todo></en-todo>item 3</div>\n" self.assertEqual(Editor.textToENML(MD_TODO), Editor.wrapENML(HTML_TODO)) wrapped = Editor.wrapENML(HTML_TODO) text = Editor.ENMLtoText(wrapped) self.assertEqual(text, MD_TODO)
def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None): result = { "title": title, "content": content, "tags": tags, "notebook": notebook, "resources": resources, } result = tools.strip(result) # if get note without params if note and title is None and content is None and tags is None and notebook is None: content = config.EDITOR_OPEN if title is None and note: result['title'] = note.title if content: content = Editor.textToENML(content, format='other') result['content'] = content ''' if content != config.EDITOR_OPEN: if isinstance(content, str) and os.path.isfile(content): logging.debug("Load content from the file") content = open(content, "r").read() logging.debug("Convert content") ''' if tags: result['tags'] = tools.strip(tags.split(',')) if notebook: #notepadGuid = Notebooks().getNoteGUID(notebook) notepadGuid = self.getNoteGUID(notebook) if notepadGuid is None: #newNotepad = Notebooks().create(notebook) newNotepad = self.create(notebook) notepadGuid = newNotepad.guid result['notebook'] = notepadGuid logging.debug("Search notebook") return result
def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None): result = { "title": title, "content": content, "tags": tags, "notebook": notebook, "resources": resources, } result = tools.strip(result) # if get note without params if note and title is None and content is None and tags is None and notebook is None: content = config.EDITOR_OPEN if title is None and note: result['title'] = note.title if content: content = Editor.textToENML(content,format='other') result['content'] = content ''' if content != config.EDITOR_OPEN: if isinstance(content, str) and os.path.isfile(content): logging.debug("Load content from the file") content = open(content, "r").read() logging.debug("Convert content") ''' if tags: result['tags'] = tools.strip(tags.split(',')) if notebook: #notepadGuid = Notebooks().getNoteGUID(notebook) notepadGuid = self.getNoteGUID(notebook) if notepadGuid is None: #newNotepad = Notebooks().create(notebook) newNotepad = self.create(notebook) notepadGuid = newNotepad.guid result['notebook'] = notepadGuid logging.debug("Search notebook") return result
def textToENML(content): format = 'vim-default' if int(vim.eval('exists("g:GeeknoteFormat")')): format = vim.eval('g:GeeknoteFormat') if format == 'pre': print 'WARNING: g:GeeknoteFormat=pre is deprecated.' if format != 'vim-default' and format != 'pre': return Editor.textToENML(content, True, format) content = content.replace('<', '<') content = content.replace('>', '>') content = content.replace('&', '&') content = unicode(content, "utf-8") contentHTML = u''.join(('<pre>', content, '</pre>')).encode("utf-8") enml = Editor.wrapENML(contentHTML) return enml
def test_not_checklist(self): wrapped = Editor.textToENML(content=" Item head[0]; ", format="markdown") self.assertEqual(wrapped, """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> <en-note><p>Item head[0]; </p> </en-note>""")
def test_htmlEscape(self): wrapped = Editor.textToENML(content="<what ever>", format="markdown") self.assertEqual(wrapped, """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> <en-note><p><what ever></p> </en-note>""")
def test_TextToENML(self): self.assertEqual(Editor.textToENML(self.MD_TEXT).replace('\n', ''), Editor.wrapENML(self.HTML_TEXT).replace('\n', ''))
def test_TODO(self): self.assertEqual( Editor.textToENML("- [ ] item 1\n- [x] item 2\n- [ ] item 3"), Editor.wrapENML( "<div><en-todo></en-todo>item 1</div><div><en-todo checked=\"true\"></en-todo>item 2</div><div><en-todo></en-todo>item 3</div>\n" ))
def test_TextToENML(self): self.assertEqual(Editor.textToENML(self.MD_TEXT), Editor.wrapENML(self.HTML_TEXT))
def test_TextToENML(self): self.assertEqual( Editor.textToENML(self.MD_TEXT).replace('\n', ''), Editor.wrapENML(self.HTML_TEXT).replace('\n', ''))
def test_TODO(self): self.assertEqual(Editor.textToENML("- [ ] item 1\n- [x] item 2\n- [ ] item 3"), Editor.wrapENML("<div><en-todo></en-todo>item 1</div><div><en-todo checked=\"true\"></en-todo>item 2</div><div><en-todo></en-todo>item 3</div>\n"))