Similar to "Insert HTML/XML tag" in Notepad2-mod. 1. Asks user for tag with attributes. 2. Surrounds current selection with tag provided by user. 3. Works without selection. 4. Knows tags without closing pair.
def openingTag(tagStr): return "<" + tagStr + ">" def closingTag(tagStr): pureTag = tagStr.partition(" ")[0] unclosedTags = ["br", "input", "img", "link", "hr", "area", "frame", "wbr", "meta", "base", "col", "isindex", "param", "basefont"] if pureTag in unclosedTags: return "" return "</" + pureTag + ">" tagStr = notepad.prompt("Tag with attributes:", "Insert HTML/XML tag") if not tagStr is None: editor.beginUndoAction() selStr = editor.getSelText() editor.replaceSel(openingTag(tagStr) + selStr + closingTag(tagStr)) editor.endUndoAction()
Log in to post a comment.
Similar to "Insert HTML/XML tag" in Notepad2-mod.
1. Asks user for tag with attributes.
2. Surrounds current selection with tag provided by user.
3. Works without selection.
4. Knows tags without closing pair.