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 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_wrapENML_success(self): text = "test" result = '''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> <en-note>test</en-note>''' self.assertEqual(Editor.wrapENML(text), result)
def test_ENMLToText(self): wrapped = Editor.wrapENML(self.HTML_TEXT) self.assertEqual(Editor.ENMLtoText(wrapped), self.MD_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" ))
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"))