@@ -70,48 +70,48 @@ static NestingLevels *nestingLevels = NULL;
70
70
* FUNCTION DEFINITIONS
71
71
*/
72
72
73
- static NestingLevel * getNestingLevel (const int kind , unsigned long adjustment_when_pop )
73
+ static NestingLevel * getNestingLevel (const int kind , unsigned long adjustmentWhenPop )
74
74
{
75
75
NestingLevel * nl ;
76
76
tagEntryInfo * e ;
77
- unsigned long line = getInputLineNumber ();
77
+ unsigned long line = getInputLineNumber ();
78
78
79
- line = (line > adjustment_when_pop )? (line - adjustment_when_pop ): 0 ;
79
+ line = (line > adjustmentWhenPop )? (line - adjustmentWhenPop ): 0 ;
80
80
81
81
while (1 )
82
82
{
83
- nl = nestingLevelsGetCurrent (nestingLevels );
83
+ nl = nestingLevelsGetCurrent (nestingLevels );
84
84
e = getEntryOfNestingLevel (nl );
85
85
if ((nl && (e == NULL )) || (e && (e -> kindIndex >= kind )))
86
- nestingLevelsPopFull (nestingLevels , HT_UINT_TO_PTR ((unsigned int )line ));
86
+ nestingLevelsPopFull (nestingLevels , HT_UINT_TO_PTR ((unsigned int )line ));
87
87
else
88
88
break ;
89
89
}
90
90
return nl ;
91
91
}
92
92
93
93
94
- static int makeMarkdownTag (const vString * const name , const int kind , const bool two_line )
94
+ static int makeMarkdownTag (const vString * const name , const int kind , const bool twoLine )
95
95
{
96
96
int r = CORK_NIL ;
97
97
98
98
if (vStringLength (name ) > 0 )
99
99
{
100
- const NestingLevel * const nl = getNestingLevel (kind , two_line ? 2 : 1 );
100
+ const NestingLevel * const nl = getNestingLevel (kind , twoLine ? 2 : 1 );
101
101
tagEntryInfo * parent = getEntryOfNestingLevel (nl );
102
102
tagEntryInfo e ;
103
103
104
104
initTagEntry (& e , vStringValue (name ), kind );
105
105
106
- if (two_line )
106
+ if (twoLine )
107
107
{
108
108
/* we want the line before the '---' underline chars */
109
- const unsigned long line = getInputLineNumber ();
109
+ const unsigned long line = getInputLineNumber ();
110
110
Assert (line > 0 );
111
111
if (line > 0 )
112
112
{
113
113
e .lineNumber -- ;
114
- e .filePosition = getInputFilePositionForLine (line - 1 );
114
+ e .filePosition = getInputFilePositionForLine (line - 1 );
115
115
}
116
116
}
117
117
@@ -126,47 +126,47 @@ static int makeMarkdownTag (const vString* const name, const int kind, const boo
126
126
127
127
static int makeSectionMarkdownTag (const vString * const name , const int kind , const char * marker )
128
128
{
129
- int r = makeMarkdownTag (name , kind , marker [0 ] != '#' );
129
+ int r = makeMarkdownTag (name , kind , marker [0 ] != '#' );
130
130
attachParserFieldToCorkEntry (r , MarkdownFields [F_MARKER ].ftype , marker );
131
131
132
- nestingLevelsPush (nestingLevels , r );
132
+ nestingLevelsPush (nestingLevels , r );
133
133
return r ;
134
134
}
135
135
136
136
137
- static vString * get_heading (const int kind , const unsigned char * line ,
138
- const int line_len , bool * delimited )
137
+ static vString * getHeading (const int kind , const unsigned char * line ,
138
+ const int lineLen , bool * delimited )
139
139
{
140
140
int pos = 0 ;
141
141
int start = kind + 1 ;
142
- int end = line_len - 1 ;
143
- vString * name = vStringNew ();
142
+ int end = lineLen - 1 ;
143
+ vString * name = vStringNew ();
144
144
145
145
Assert (kind >= 0 && kind < K_SECTION_COUNT );
146
- Assert (line_len > start );
146
+ Assert (lineLen > start );
147
147
148
148
* delimited = false;
149
- while (isspace (line [pos ])) ++ pos ;
149
+ while (isspace (line [pos ])) ++ pos ;
150
150
while (line [end ] == line [pos ] && end - 1 >= 0 && line [end - 1 ] != '\\' )
151
151
{
152
152
-- end ;
153
153
* delimited = true;
154
154
}
155
- while (isspace (line [start ])) ++ start ;
156
- while (isspace (line [end ])) -- end ;
155
+ while (isspace (line [start ])) ++ start ;
156
+ while (isspace (line [end ])) -- end ;
157
157
158
158
if (start <= end )
159
- vStringNCatS (name , (const char * )(& (line [start ])), end - start + 1 );
159
+ vStringNCatS (name , (const char * )(& (line [start ])), end - start + 1 );
160
160
161
161
return name ;
162
162
}
163
163
164
164
165
- static int get_first_char_pos (const unsigned char * line , int line_len , bool * indented )
165
+ static int getFirstCharPos (const unsigned char * line , int lineLen , bool * indented )
166
166
{
167
167
int indent = 0 ;
168
168
int i ;
169
- for (i = 0 ; i < line_len && isspace (line [i ]); i ++ )
169
+ for (i = 0 ; i < lineLen && isspace (line [i ]); i ++ )
170
170
indent += line [i ] == '\t' ? 4 : 1 ;
171
171
* indented = indent >= 4 ;
172
172
return i ;
@@ -178,30 +178,30 @@ static void fillEndField (NestingLevel *nl, void *ctxData)
178
178
tagEntryInfo * e = getEntryOfNestingLevel (nl );
179
179
if (e )
180
180
{
181
- unsigned long line = (unsigned long )(HT_PTR_TO_UINT (ctxData ));
181
+ unsigned long line = (unsigned long )(HT_PTR_TO_UINT (ctxData ));
182
182
e -> extensionFields .endLine = line ;
183
183
}
184
184
}
185
185
186
186
187
- static void findMarkdownTags (void )
187
+ static void findMarkdownTags (void )
188
188
{
189
- vString * prev_line = vStringNew ();
190
- vString * codeLang = vStringNew ();
189
+ vString * prevLine = vStringNew ();
190
+ vString * codeLang = vStringNew ();
191
191
const unsigned char * line ;
192
- char in_code_char = 0 ;
192
+ char inCodeChar = 0 ;
193
193
long startSourceLineNumber = 0 ;
194
194
long startLineNumber = 0 ;
195
195
bool inPreambule = false;
196
196
197
- nestingLevels = nestingLevelsNewFull (0 , fillEndField );
197
+ nestingLevels = nestingLevelsNewFull (0 , fillEndField );
198
198
199
- while ((line = readLineFromInputFile ()) != NULL )
199
+ while ((line = readLineFromInputFile ()) != NULL )
200
200
{
201
- int line_len = strlen ((const char * ) line );
202
- bool line_processed = false;
201
+ int lineLen = strlen ((const char * ) line );
202
+ bool lineProcessed = false;
203
203
bool indented ;
204
- int pos = get_first_char_pos (line , line_len , & indented );
204
+ int pos = getFirstCharPos (line , lineLen , & indented );
205
205
int lineNum = getInputLineNumber ();
206
206
207
207
if (lineNum == 1 || inPreambule )
@@ -217,97 +217,97 @@ static void findMarkdownTags(void)
217
217
if (line [pos ] == '`' || line [pos ] == '~' )
218
218
{
219
219
char c = line [pos ];
220
- char other_c = c == '`' ? '~' : '`' ;
221
- int n_same ;
222
- for (n_same = pos + 1 ; line [n_same ] == line [pos ]; ++ n_same );
220
+ char otherC = c == '`' ? '~' : '`' ;
221
+ int nSame ;
222
+ for (nSame = pos + 1 ; line [nSame ] == line [pos ]; ++ nSame );
223
223
224
- if (in_code_char != other_c && n_same >= 3 )
224
+ if (inCodeChar != otherC && nSame >= 3 )
225
225
{
226
- in_code_char = in_code_char ? 0 : c ;
227
- if (in_code_char == c && strstr ((const char * )(line + pos + n_same ), "```" ) != NULL )
228
- in_code_char = 0 ;
229
- else if (in_code_char )
226
+ inCodeChar = inCodeChar ? 0 : c ;
227
+ if (inCodeChar == c && strstr ((const char * )(line + pos + nSame ), "```" ) != NULL )
228
+ inCodeChar = 0 ;
229
+ else if (inCodeChar )
230
230
{
231
231
startSourceLineNumber = getSourceLineNumber ();
232
232
startLineNumber = getInputLineNumber ();
233
- vStringClear (codeLang );
234
- vStringCatS (codeLang , (const char * )(line + pos + n_same ));
235
- vStringStripLeading (codeLang );
236
- vStringStripTrailing (codeLang );
233
+ vStringClear (codeLang );
234
+ vStringCatS (codeLang , (const char * )(line + pos + nSame ));
235
+ vStringStripLeading (codeLang );
236
+ vStringStripTrailing (codeLang );
237
237
}
238
238
else
239
239
{
240
240
long endLineNumber = getInputLineNumber () - 1 ;
241
241
if (codeLang -> size > 0 )
242
- makePromise (vStringValue (codeLang ), startLineNumber , 0 ,
242
+ makePromise (vStringValue (codeLang ), startLineNumber , 0 ,
243
243
endLineNumber , 0 , startSourceLineNumber );
244
244
}
245
245
246
- line_processed = true;
246
+ lineProcessed = true;
247
247
}
248
248
}
249
249
250
250
/* code block */
251
- if (in_code_char )
252
- line_processed = true;
251
+ if (inCodeChar )
252
+ lineProcessed = true;
253
253
254
254
/* code block using indent */
255
255
else if (indented )
256
- line_processed = true;
256
+ lineProcessed = true;
257
257
258
258
/* if it's a title underline, or a delimited block marking character */
259
259
else if (line [pos ] == '=' || line [pos ] == '-' || line [pos ] == '#' || line [pos ] == '>' )
260
260
{
261
- int n_same ;
262
- for (n_same = pos + 1 ; line [n_same ] == line [pos ]; ++ n_same );
261
+ int nSame ;
262
+ for (nSame = pos + 1 ; line [nSame ] == line [pos ]; ++ nSame );
263
263
264
264
/* quote */
265
265
if (line [pos ] == '>' )
266
- ; /* just to make sure line_processed = true so it won't be in a heading */
266
+ ; /* just to make sure lineProcessed = true so it won't be in a heading */
267
267
/* is it a two line title */
268
268
else if (line [pos ] == '=' || line [pos ] == '-' )
269
269
{
270
270
char marker [2 ] = { line [pos ], '\0' };
271
271
int kind = line [pos ] == '=' ? K_CHAPTER : K_SECTION ;
272
- bool whitespace_terminated = true;
272
+ bool whitespaceTerminated = true;
273
273
274
- for (int i = pos + n_same ; i < line_len ; i ++ )
274
+ for (int i = pos + nSame ; i < lineLen ; i ++ )
275
275
{
276
- if (!isspace (line [i ]))
276
+ if (!isspace (line [i ]))
277
277
{
278
- whitespace_terminated = false;
278
+ whitespaceTerminated = false;
279
279
break ;
280
280
}
281
281
}
282
282
283
- vStringStripLeading ( prev_line );
284
- vStringStripTrailing ( prev_line );
285
- if (whitespace_terminated && vStringLength ( prev_line ) > 0 )
286
- makeSectionMarkdownTag ( prev_line , kind , marker );
283
+ vStringStripLeading ( prevLine );
284
+ vStringStripTrailing ( prevLine );
285
+ if (whitespaceTerminated && vStringLength ( prevLine ) > 0 )
286
+ makeSectionMarkdownTag ( prevLine , kind , marker );
287
287
}
288
288
/* otherwise is it a one line title */
289
- else if (line [pos ] == '#' && n_same <= K_SECTION_COUNT && isspace (line [n_same ]))
289
+ else if (line [pos ] == '#' && nSame <= K_SECTION_COUNT && isspace (line [nSame ]))
290
290
{
291
- int kind = n_same - 1 ;
291
+ int kind = nSame - 1 ;
292
292
bool delimited = false;
293
- vString * name = get_heading (kind , line , line_len , & delimited );
294
- if (vStringLength (name ) > 0 )
295
- makeSectionMarkdownTag (name , kind , delimited ? "##" : "#" );
296
- vStringDelete (name );
293
+ vString * name = getHeading (kind , line , lineLen , & delimited );
294
+ if (vStringLength (name ) > 0 )
295
+ makeSectionMarkdownTag (name , kind , delimited ? "##" : "#" );
296
+ vStringDelete (name );
297
297
}
298
298
299
- line_processed = true;
299
+ lineProcessed = true;
300
300
}
301
301
302
- vStringClear ( prev_line );
303
- if (!line_processed )
304
- vStringCatS ( prev_line , (const char * ) line );
302
+ vStringClear ( prevLine );
303
+ if (!lineProcessed )
304
+ vStringCatS ( prevLine , (const char * ) line );
305
305
}
306
- vStringDelete ( prev_line );
307
- vStringDelete (codeLang );
306
+ vStringDelete ( prevLine );
307
+ vStringDelete (codeLang );
308
308
{
309
309
unsigned int line = (unsigned int )getInputLineNumber ();
310
- nestingLevelsFreeFull (nestingLevels , HT_UINT_TO_PTR (line ));
310
+ nestingLevelsFreeFull (nestingLevels , HT_UINT_TO_PTR (line ));
311
311
}
312
312
}
313
313
@@ -320,9 +320,9 @@ extern parserDefinition* MarkdownParser (void)
320
320
def -> extensions = extensions ;
321
321
def -> useCork = CORK_QUEUE ;
322
322
def -> kindTable = MarkdownKinds ;
323
- def -> kindCount = ARRAY_SIZE (MarkdownKinds );
323
+ def -> kindCount = ARRAY_SIZE (MarkdownKinds );
324
324
def -> fieldTable = MarkdownFields ;
325
- def -> fieldCount = ARRAY_SIZE (MarkdownFields );
325
+ def -> fieldCount = ARRAY_SIZE (MarkdownFields );
326
326
def -> defaultScopeSeparator = "\"\"" ;
327
327
def -> parser = findMarkdownTags ;
328
328
0 commit comments