Preformatted text should show what I pasted


(tito) #1

this is original text

this is what this forums shows:

import re, sublime, sublime_plugin

class SpaceToTabsListener(sublime_plugin.EventListener):
	def on_post_text_command(self, view, command_name, args):
		if command_name == 'insert' and args['characters'] == '\n' and not view.settings().get('translate_tabs_to_spaces'):
			view.run_command('unexpand_tabs', {"set_translate_tabs":True})

class SpaceToTabsCommand(sublime_plugin.TextCommand):
	def run(self, edit):
		view = self.view
		for region in reversed(view.sel()):
			indentation = sublime.Region(view.line(region).begin(), region.end())
			content = view.substr(indentation)
			if'^\t+ +', content):
				view.replace(edit, indentation, re.sub('^(\t+)( +)', '\\1\t', content))

Escape sequence for \\\1?
(Gerhard Schlager) #2

Here’s the diff of the raw text and the rendered code:

And here’s the part that’s different:
is shown as '\\1\t'

It works with markdown-it.

(Sam Saffron) #3

Fixed per:

Rebaked the OP and all looks good.

(Sam Saffron) #4