@@ -74,7 +74,6 @@ def main():
74
74
75
75
76
76
def process_code (read_filehandle , text_filehandle , line , linenum , sourcefile , codedir , name , index , indent_depth ):
77
-
78
77
fenced = (line .strip () == '```' )
79
78
if fenced :
80
79
try :
@@ -94,18 +93,18 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
94
93
if comment_idx >= 0 :
95
94
no_comment_line = line [:comment_idx ]
96
95
text_filehandle .write (line [comment_idx + 2 :])
97
- if (not has_actual_code
98
- and not line .strip ().startswith ('//' )
99
- and not line .strip ().startswith ('???' )
100
- and not line .strip () == '' ):
101
- has_actual_code = True
96
+
97
+ if (not has_actual_code
98
+ and not line .strip ().startswith ('//' )
99
+ and not line .strip ().startswith ('???' )
100
+ and not line .strip () == '' ):
101
+ has_actual_code = True
102
102
else :
103
103
# write empty line so line numbers stay stable
104
104
text_filehandle .write ('' )
105
105
106
106
if (not line .strip () == '```' ):
107
-
108
- if ('???' in no_comment_line or '...' in no_comment_line ):
107
+ if ('???' == no_comment_line or '...' == no_comment_line ):
109
108
has_question_marks = True
110
109
linebuffer .append (dedent (line ) if not fenced else line )
111
110
try :
@@ -115,10 +114,8 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
115
114
line = ''
116
115
break
117
116
codefile = os .path .join (codedir , '%s%s.cpp' % (name , index ))
118
-
119
117
if fenced :
120
118
text_filehandle .write ('' )
121
-
122
119
if (has_actual_code and not has_question_marks ):
123
120
# add commonly used headers, so that lines can compile
124
121
with io .open (codefile , 'w' ) as code_filehandle :
@@ -145,6 +142,7 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
145
142
146
143
147
144
def is_code (line , indent_depth = 4 ):
145
+ '''returns the indent depth, 0 means not code in markup'''
148
146
if line .startswith (' ' * indent_depth ):
149
147
return len (line ) - len (line .lstrip (' ' ))
150
148
return 0
@@ -171,6 +169,7 @@ def get_marker(line):
171
169
namematch = NAMED_A_TAG_REGEX .match (line )
172
170
if namematch :
173
171
return namematch .group (1 ) # group 0 is full match
172
+
174
173
return None
175
174
176
175
if __name__ == '__main__' :
0 commit comments