MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / line_offset

Method line_offset

markdown/htmlparser.py:169–179  ·  view source on GitHub ↗

Returns char index in `self.rawdata` for the start of the current line.

(self)

Source from the content-addressed store, hash-verified

167
168 @property
169 def line_offset(self) -> int:
170 """Returns char index in `self.rawdata` for the start of the current line. """
171 for ii in range(len(self.lineno_start_cache)-1, self.lineno-1):
172 last_line_start_pos = self.lineno_start_cache[ii]
173 lf_pos = self.rawdata.find('\n', last_line_start_pos)
174 if lf_pos == -1:
175 # No more newlines found. Use end of raw data as start of line beyond end.
176 lf_pos = len(self.rawdata)
177 self.lineno_start_cache.append(lf_pos+1)
178
179 return self.lineno_start_cache[self.lineno-1]
180
181 def at_line_start(self) -> bool:
182 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected