mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
Minor fix to python code extractor, dedent by indentation amount
This commit is contained in:
@@ -105,7 +105,7 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
|
|||||||
if (not line.strip() == '```'):
|
if (not line.strip() == '```'):
|
||||||
if ('???' == no_comment_line or '...' == no_comment_line):
|
if ('???' == no_comment_line or '...' == no_comment_line):
|
||||||
has_question_marks = True
|
has_question_marks = True
|
||||||
linebuffer.append(dedent(line) if not fenced else line)
|
linebuffer.append(dedent(line, indent_depth) if not fenced else line)
|
||||||
try:
|
try:
|
||||||
line = read_filehandle.next()
|
line = read_filehandle.next()
|
||||||
linenum += 1
|
linenum += 1
|
||||||
@@ -147,7 +147,7 @@ def is_code(line, indent_depth = 4):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def is_inside_code(line, indent_depth):
|
def is_inside_code(line, indent_depth):
|
||||||
return is_code(line, indent_depth) or line.strip() == ''
|
return is_code(line, indent_depth) > 0 or line.strip() == ''
|
||||||
|
|
||||||
def stripped(line):
|
def stripped(line):
|
||||||
# Remove well-formed html tags, fixing mistakes by legitimate users
|
# Remove well-formed html tags, fixing mistakes by legitimate users
|
||||||
@@ -155,9 +155,9 @@ def stripped(line):
|
|||||||
sline = re.sub('[()\[\]#*]', ' ', line)
|
sline = re.sub('[()\[\]#*]', ' ', line)
|
||||||
return sline
|
return sline
|
||||||
|
|
||||||
def dedent(line):
|
def dedent(line, indent_depth):
|
||||||
if line.startswith(' '):
|
if line.startswith(' ' * indent_depth):
|
||||||
return line[4:]
|
return line[indent_depth:]
|
||||||
if line.startswith('\t'):
|
if line.startswith('\t'):
|
||||||
return line[1:]
|
return line[1:]
|
||||||
return line
|
return line
|
||||||
|
|||||||
Reference in New Issue
Block a user