MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / detab

Method detab

markdown/blockprocessors.py:39–50  ·  view source on GitHub ↗

Remove a tab from the front of each line of the given text.

(self, text)

Source from the content-addressed store, hash-verified

37 return None
38
39 def detab(self, text):
40 """ Remove a tab from the front of each line of the given text. """
41 newtext = []
42 lines = text.split('\n')
43 for line in lines:
44 if line.startswith(' '*markdown.TAB_LENGTH):
45 newtext.append(line[markdown.TAB_LENGTH:])
46 elif not line.strip():
47 newtext.append('')
48 else:
49 break
50 return '\n'.join(newtext), '\n'.join(lines[len(newtext):])
51
52 def looseDetab(self, text, level=1):
53 """ Remove a tab from front of lines but allowing dedented lines. """

Callers 1

runMethod · 0.45

Calls 2

splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected