Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.

Commit 24f5431

Browse files
committed
fix pygments weirdness with 2+ indented single line comments
1 parent 94d5edc commit 24f5431

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pugdebug/syntaxer.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,17 @@ def format(self, tokensource, outfile):
156156
# If we advanced a block
157157
if current_block_number < block_number:
158158
block_text = block.text()
159-
# Where do we start in the current block, whitespace included?
160-
start_in_block = len(block_text) - len(block_text.lstrip())
161-
current_block_number = block_number
159+
160+
# When there are 2 or more indented one line comments
161+
# Except for the 1st line, pygments sees the indents as tokens
162+
# so if the current value stripped of whitespace from the left
163+
# is an empty string, skip it
164+
if value.lstrip() != '':
165+
# Where do we start in the current block,
166+
# whitespace included?
167+
start_in_block = len(block_text) - len(block_text.lstrip())
168+
169+
current_block_number = block_number
162170

163171
# If this block has no formats yet
164172
if block_number not in self.formats:

0 commit comments

Comments
 (0)