@@ -170,8 +170,7 @@ function inline(s, no_links, replacements, result, t, i, x)
170
170
t = t substr (s, 1 , i - 1 ) result[ " html" ]
171
171
s = result[ " rest" ]
172
172
} else { # Apparently not a delimiter, take it literally
173
- push(replacements, esc_html(x[ 0 ] ))
174
- t = t substr (s, 1 , i - 1 ) " \002 " size(replacements) " \003 "
173
+ t = t substr (s, 1 , i - 1 ) " \002 " push(replacements, esc_html(x[ 0 ] )) " \003 "
175
174
s = substr (s, i + length (x[ 0 ] ))
176
175
}
177
176
s = t s
@@ -188,8 +187,7 @@ function inline(s, no_links, replacements, result, t, i, x)
188
187
t = t substr (s, 1 , i - 1 ) result[ " html" ]
189
188
s = result[ " rest" ]
190
189
} else { # Apparently not an opening delimiter, skip it
191
- push(replacements, x[ 0 ] )
192
- t = t substr (s, 1 , i - 1 ) " \002 " size(replacements) " \003 "
190
+ t = t substr (s, 1 , i - 1 ) " \002 " push(replacements, x[ 0 ] ) " \003 "
193
191
s = substr (s, i + length (x[ 0 ] ))
194
192
}
195
193
s = t s
@@ -205,16 +203,14 @@ function inline(s, no_links, replacements, result, t, i, x)
205
203
t = t substr (s, 1 , i - 1 ) result[ " html" ]
206
204
s = result[ " rest" ]
207
205
} else { # Apparently not a valid delimiter. Skip it.
208
- push(replacements, x[ 0 ] )
209
- t = t substr (s, 1 , i - 1 ) " \002 " size(replacements)" \003 "
206
+ t = t substr (s, 1 , i - 1 ) " \002 " push(replacements, x[ 0 ] ) " \003 "
210
207
s = substr (s, i + length (x[ 0 ] ))
211
208
}
212
209
s = t s
213
210
214
211
# Replace hard line breaks by <br> and remove backslash escapes.
215
212
#
216
- push(replacements, " <br />\n " )
217
- t = " \002 " size(replacements) " \003 "
213
+ t = " \002 " push(replacements, " <br />\n " ) " \003 "
218
214
s = awk:: gensub (/ \n /, " \n " , " g" ,
219
215
awk:: gensub (/( + | \\ )\n /, t, " g" , esc_html(unesc_md(s))))
220
216
@@ -260,8 +256,7 @@ function inline_code_span(s, i, replacements, result,
260
256
261
257
# Store HTML code in replacements.
262
258
t = " <code>" esc_html(content) " </code>"
263
- push(replacements, t)
264
- n = size(replacements)
259
+ n = push(replacements, t)
265
260
266
261
# Return result.
267
262
result[ " html" ] = " \002 " n " \003 "
@@ -315,8 +310,7 @@ function inline_autolink(s, i, no_links, replacements, result,
315
310
return 0
316
311
}
317
312
318
- push(replacements, t) # Store the HTML code in replacements
319
- n = size(replacements) # Get the index where it was stored
313
+ n = push(replacements, t) # Store the HTML code in replacements, get its index
320
314
result[ " html" ] = " \002 " n " \003 " # The tag to replace the auutolink with
321
315
result[ " rest" ] = substr (s, length (x[ 0 ] ) + 1 )
322
316
# print "Found autolink <" n "> = " t > "/dev/stderr"
@@ -356,8 +350,7 @@ function inline_html_tag(s, i, replacements, result,
356
350
match (s, /^ <![a -zA -Z ][^ > ]* > /, x) ||
357
351
match (s, /^ <\? ([^ ? > ]| \? [^ > ])* \? > /, x)) {
358
352
t = x[ 0 ] # Copy the tag verbatim
359
- push(replacements, t) # Store the HTML code in replacements
360
- n = size(replacements) # Get the index where it was stored
353
+ n = push(replacements, t) # # Store HTML code in replacements, get its index
361
354
result[ " html" ] = " \002 " n " \003 " # The tag to replace the auutolink with
362
355
result[ " rest" ] = substr (s, length (x[ 0 ] ) + 1 )
363
356
# print "Found HTML tag <" n "> = " t > "/dev/stderr"
@@ -414,8 +407,7 @@ function inline_link_or_image(s, i, no_links, replacements, result,
414
407
inline_html_tag(s, j, replacements, result1)) {
415
408
t = t substr (s, 1 , j - 1 ) result1[ " html" ] ; s = result1[ " rest" ]
416
409
} else { # delimiter that does not start anything
417
- push(replacements, esc_html(x[ 0 ] ))
418
- t = t substr (s, 1 , i - 1 ) " \002 " size(replacements) " \003 "
410
+ t = t substr (s, 1 , i- 1 ) " \002 " push(replacements, esc_html(x[ 0 ] )) " \003 "
419
411
s = substr (s, i + length (x[ 0 ] ))
420
412
}
421
413
} else if (x[ 0 ] == " ![" ) {
@@ -424,8 +416,7 @@ function inline_link_or_image(s, i, no_links, replacements, result,
424
416
t = t substr (s, 1 , j - 1 ) result1[ " html" ] ; s = result1[ " rest" ]
425
417
} else { # delimiter that does not start anything
426
418
n++
427
- push(replacements, esc_html(x[ 0 ] ))
428
- t = t substr (s, 1 , i - 1 ) " \002 " size(replacements) " \003 "
419
+ t = t substr (s, 1 , i- 1 ) " \002 " push(replacements, esc_html(x[ 0 ] )) " \003 "
429
420
s = substr (s, i + length (x[ 0 ] ))
430
421
}
431
422
} else if (x[ 0 ] == " [" ) {
@@ -512,8 +503,7 @@ function inline_link_or_image(s, i, no_links, replacements, result,
512
503
513
504
# Store the HTML code in replacements at index n and return a tag
514
505
# "<n>".
515
- push(replacements, u)
516
- result[ " html" ] = " \002 " size(replacements) " \003 "
506
+ result[ " html" ] = " \002 " push(replacements, u) " \003 "
517
507
result[ " rest" ] = s
518
508
# print "\"" u "\" -> " size(replacements) > "/dev/stderr"
519
509
return 1
@@ -611,8 +601,7 @@ function inline_emphasis(s, i, no_links, replacements, result,
611
601
if (j != 0 ) {
612
602
# We found and processed an opening delimiter. Replace the
613
603
# processed part in the string s by the result of processing.
614
- push(replacements, result1[ " html" ] )
615
- t = " \002 " size(replacements) " \003 "
604
+ t = " \002 " push(replacements, result1[ " html" ] ) " \003 "
616
605
result[ " html" ] = x[ 1 ] substr (x[ 2 ] , 1 , j - 1 ) t
617
606
result[ " rest" ] = result1[ " rest" ]
618
607
s = result[ " html" ] result[ " rest" ]
@@ -632,16 +621,12 @@ function inline_emphasis(s, i, no_links, replacements, result,
632
621
# how many *'s were matched (= n).
633
622
n = min(length (x[ 1 ] ), closinglen)
634
623
for (j = n; j > 1 ; j -= 2 ) {
635
- push(replacements, " <strong>" )
636
- t = " \002 " size(replacements) " \003 " t
637
- push(replacements, " </strong>" )
638
- t = t " \002 " size(replacements) " \003 "
624
+ t = " \002 " push(replacements, " <strong>" ) " \003 " t
625
+ t = t " \002 " push(replacements, " </strong>" ) " \003 "
639
626
}
640
627
if (n % 2 == 1 ) {
641
- push(replacements, " <em>" )
642
- t = " \002 " size(replacements) " \003 " t
643
- push(replacements, " </em>" )
644
- t = t " \002 " size(replacements) " \003 "
628
+ t = " \002 " push(replacements, " <em>" ) " \003 " t
629
+ t = t " \002 " push(replacements, " </em>" ) " \003 "
645
630
}
646
631
647
632
# The result so far consists of any remaining part of the
@@ -708,10 +693,8 @@ function inline_strikethrough(s, i, no_links, replacements, result,
708
693
# Process the text between the two delimiters and enclose the result
709
694
# in <del> and </del>.
710
695
t = inline(substr (s, 1 , j - 1 ), no_links, replacements)
711
- push(replacements, " <del>" )
712
- t = " \002 " size(replacements) " \003 " t
713
- push(replacements, " </del>" )
714
- t = t " \002 " size(replacements) " \003 "
696
+ t = " \002 " push(replacements, " <del>" ) " \003 " t
697
+ t = t " \002 " push(replacements, " </del>" ) " \003 "
715
698
716
699
result[ " html" ] = t
717
700
result[ " rest" ] = substr (s, j + length (x[ 1 ] ))
@@ -1475,7 +1458,7 @@ function esc_url(s)
1475
1458
# queue/stack is empty.
1476
1459
1477
1460
1478
- # push -- add a value to a stack or a queue, return the value
1461
+ # push -- add a value to a stack or a queue, return its index
1479
1462
function push (stack , value )
1480
1463
{
1481
1464
# If stack is uninitialized, initialize it
@@ -1484,7 +1467,7 @@ function push(stack, value)
1484
1467
stack[ " last" ] = 0
1485
1468
}
1486
1469
stack[ ++ stack[ " last" ]] = value
1487
- return value
1470
+ return stack [ " last " ]
1488
1471
}
1489
1472
1490
1473
@@ -1507,7 +1490,7 @@ function top(stack)
1507
1490
}
1508
1491
1509
1492
1510
- # shift -- add an item at the start of a queue, return the item
1493
+ # shift -- add an item at the start of a queue, return its index
1511
1494
function shift (queue , value )
1512
1495
{
1513
1496
# If the queue is uninitialized, initialize it
@@ -1516,7 +1499,7 @@ function shift(queue, value)
1516
1499
queue[ " last" ] = 0
1517
1500
}
1518
1501
queue[ -- queue[ " first" ]] = value
1519
- return value
1502
+ return queue [ " first " ]
1520
1503
}
1521
1504
1522
1505
0 commit comments