def highlightCode(self, code, language): #converting the html to platin td = QTextDocument() td.setHtml(code) print("the plain text is here : " + td.toPlainText()) codeLexer = get_lexer_by_name(language) f = open("highlightTest.html", 'wb') #fi = open("highlightTest.png",'wb') #style = get_style_by_name("native") formatter = HtmlFormatter(full=True, noclasses=True, encoding="UTF-8") #imgFormater = ImageFormatter() result = highlight(td.toPlainText(), codeLexer, formatter) td.setHtml(result.decode("UTF-8")) print(td.toHtml()) return td.toHtml()
def testUndoRedo(self): text = 'foobar' doc = QTextDocument(text) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text) cursor = QTextCursor(doc) doc.undo(cursor) self.assertTrue(doc.isRedoAvailable()) self.assertFalse(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), '') doc.redo(cursor) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text)
def testUndoRedo(self): text = 'foobar' doc = QTextDocument(text) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text) cursor = QTextCursor(doc) doc.undo(cursor) self.assertTrue(doc.isRedoAvailable()) self.assertFalse(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), '') doc.redo(cursor) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text)