def on_pre_save(self, view): """Runs Pretty Markdown pre-save actions""" extension = os.path.splitext(view.file_name())[1][1:] if extension in pretty_markdown.settings().get('format_files_with_extension'): if (pretty_markdown.settings().get("format_on_save")): # save a copy of the file before editting r = sublime.Region(0, view.size()) text = view.substr(r) self.save_text(text) view.run_command("format_markdown")
def modify(self, text): """Converts any horizontal rule variation to the version defined in the settings file. A horizontal rule is defined by three or more hyphens, asterisks, or underscores with optional spaces in between. """ horizontal_rule = pretty_markdown.settings().get('horizontal_rule_style') return horizontal_rule_utils.convert_horizontal_rules(text, horizontal_rule)
def modify(self, text): """Alternates the delimiters in unordered lists according to their indentation.""" delimiters = pretty_markdown.settings().get('unordered_list_delimiters') return list_utils.alternate_unordered_list_delimiters(text, delimiters)
def run(self, edit): """Runs all formatting functions.""" [self.view.run_command(function) for function in pretty_markdown.command_names() if pretty_markdown.settings().get(function)]
def modify(self, text): """Converts any bold implementation into the one defined in the settings.""" bold_character = pretty_markdown.settings().get('bold_character') return bold_utils.convert_bolds(text, bold_character)
def modify(self, text): """Converts any italics implementation into the one defined in the settings.""" italics_character = pretty_markdown.settings().get('italics_character') return italic_utils.convert_italics(text, italics_character)