MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / _number

Method _number

markdown/extensions/codehilite.py:111–125  ·  view source on GitHub ↗

Use for line numbering

(self, txt)

Source from the content-addressed store, hash-verified

109 return txt
110
111 def _number(self, txt):
112 """ Use <ol> for line numbering """
113 # Fix Whitespace
114 txt = txt.replace('\t', ' '*TAB_LENGTH)
115 txt = txt.replace(" "*4, "&nbsp; &nbsp; ")
116 txt = txt.replace(" "*3, "&nbsp; &nbsp;")
117 txt = txt.replace(" "*2, "&nbsp; ")
118
119 # Add line numbers
120 lines = txt.splitlines()
121 txt = '<div class="codehilite"><pre><ol>\n'
122 for line in lines:
123 txt += '\t<li>%s</li>\n'% line
124 txt += '</ol></pre></div>\n'
125 return txt
126
127
128 def _getLang(self):

Callers 1

hiliteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected