# -*- coding: utf-8 -*- ''' :Title Save as Simple HTML :Author Flying Meat :Website http://flyingmeat.com/ :Planguage Python :Requires VoodooPad 3.5+ :Description This plugin will open up a save window, allowing you to export the current page as super simple plain HTML. EOD ''' import Foundation import AppKit VPScriptSuperMenuTitle = None VPScriptMenuTitle = "Save as Simple HTML" def main(windowController, *args, **kwargs): document = windowController.document() textView = windowController.textView() page = windowController.currentPage() range = Foundation.NSMakeRange(0, textView.textStorage().length()) data, err = textView.textStorage().dataFromRange_documentAttributes_error_(range, {'DocumentType':'NSHTML'}, None) savePanel = AppKit.NSSavePanel.savePanel() savePanel.setTitle_("Save as HTML") button = savePanel.runModalForDirectory_file_(None, page.displayName() + ".html") if button == AppKit.NSFileHandlingPanelOKButton: data.writeToFile_atomically_(savePanel.filename(), True)