MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / detab

Method detab

markdown/blockprocessors.py:85–98  ·  view source on GitHub ↗

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

(self, text: str, length: int | None = None)

Source from the content-addressed store, hash-verified

83 return None
84
85 def detab(self, text: str, length: int | None = None) -> tuple[str, str]:
86 """ Remove a tab from the front of each line of the given text. """
87 if length is None:
88 length = self.tab_length
89 newtext = []
90 lines = text.split('\n')
91 for line in lines:
92 if line.startswith(' ' * length):
93 newtext.append(line[length:])
94 elif not line.strip():
95 newtext.append('')
96 else:
97 break
98 return '\n'.join(newtext), '\n'.join(lines[len(newtext):])
99
100 def looseDetab(self, text: str, level: int = 1) -> str:
101 """ Remove a tab from front of lines but allowing dedented lines. """

Callers 1

runMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected