--- a/QScintilla/MarkupProviders/MarkdownProvider.py Sun Jan 08 18:51:55 2017 +0100 +++ b/QScintilla/MarkupProviders/MarkdownProvider.py Sun Jan 08 18:52:16 2017 +0100 @@ -205,10 +205,13 @@ @param editor reference to the editor to work on @type Editor """ + if editor is None: + return + from .HyperlinkMarkupDialog import HyperlinkMarkupDialog dlg = HyperlinkMarkupDialog(False, True) if dlg.exec_() == QDialog.Accepted: - text, target, title = dlg.getData() + text, target, title = dlg.getData() link = "[{0}]".format(text) if target and title: @@ -250,3 +253,65 @@ cline, cindex = editor.getCursorPosition() editor.setCursorPosition(cline + 3, 0) editor.endUndoAction() + + def hasQuote(self): + """ + Public method to indicate the availability of block quote markup. + + @return flag indicating the availability of block quote markup + @rtype bool + """ + return True + + def quote(self, editor): + """ + Public method to generate block quote text. + + @param editor reference to the editor to work on + @type Editor + """ + if editor is None: + return + + editor.beginUndoAction() + markup = "> " + sline, sindex, eline, eindex = editor.getSelection() + for line in range(sline, eline + 1 if eindex > 0 else eline): + editor.insertAt(markup, line, 0) + editor.endUndoAction() + + def hasImage(self): + """ + Public method to indicate the availability of image markup. + + @return flag indicating the availability of image markup + @rtype bool + """ + return True + + def image(self, editor): + """ + Public method to generate image text. + + @param editor reference to the editor to work on + @type Editor + """ + if editor is None: + return + + from .ImageMarkupDialog import ImageMarkupDialog + dlg = ImageMarkupDialog(ImageMarkupDialog.MarkDownMode) + if dlg.exec_() == QDialog.Accepted: + address, altText, title, originalSize, width, height = \ + dlg.getData() + + if title: + markup = ''.format(altText, address, title) + else: + markup = ''.format(altText, address) + + editor.beginUndoAction() + editor.insert(markup) + cline, cindex = editor.getCursorPosition() + editor.setCursorPosition(cline, cindex + len(markup)) + editor.endUndoAction()