papagaio 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/tests/tests.json +51 -51
package/README.md
CHANGED
package/package.json
CHANGED
package/tests/tests.json
CHANGED
|
@@ -422,295 +422,295 @@
|
|
|
422
422
|
},
|
|
423
423
|
{
|
|
424
424
|
"id": 71,
|
|
425
|
-
"name": "
|
|
425
|
+
"name": "Simple Variables",
|
|
426
426
|
"code": "pattern {$x} {$x}\nhello",
|
|
427
427
|
"expected": "hello"
|
|
428
428
|
},
|
|
429
429
|
{
|
|
430
430
|
"id": 72,
|
|
431
|
-
"name": "
|
|
431
|
+
"name": "Multiple Variables",
|
|
432
432
|
"code": "pattern {$x $y $z} {$z, $y, $x}\napple banana cherry",
|
|
433
433
|
"expected": "cherry, banana, apple"
|
|
434
434
|
},
|
|
435
435
|
{
|
|
436
436
|
"id": 73,
|
|
437
|
-
"name": "
|
|
437
|
+
"name": "Flexible Whitespace",
|
|
438
438
|
"code": "pattern {$x$$and$$$y} {$x & $y}\nhello and world",
|
|
439
439
|
"expected": "hello & world"
|
|
440
440
|
},
|
|
441
441
|
{
|
|
442
442
|
"id": 74,
|
|
443
|
-
"name": "
|
|
443
|
+
"name": "Flexible Whitespace (compact)",
|
|
444
444
|
"code": "pattern {$x$$and$$$y} {$x & $y}\nhello and world",
|
|
445
445
|
"expected": "hello & world"
|
|
446
446
|
},
|
|
447
447
|
{
|
|
448
448
|
"id": 75,
|
|
449
|
-
"name": "
|
|
450
|
-
"code": "pattern {$block content {(}{)}} {[$content]}\ndata (
|
|
449
|
+
"name": "Block with parentheses",
|
|
450
|
+
"code": "pattern {$name $block content {(}{)}} {[$content]}\ndata (hello world)",
|
|
451
451
|
"expected": "[hello world]"
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"id": 76,
|
|
455
|
-
"name": "
|
|
455
|
+
"name": "Block with custom delimiters <<>>",
|
|
456
456
|
"code": "pattern {$block data {<<}{>>}} {DATA: $data}\n<<json stuff>>",
|
|
457
457
|
"expected": "DATA: json stuff"
|
|
458
458
|
},
|
|
459
459
|
{
|
|
460
460
|
"id": 77,
|
|
461
|
-
"name": "
|
|
461
|
+
"name": "Multiple Blocks in pattern",
|
|
462
462
|
"code": "pattern {$block a {(}{)}, $block b {[}{]}} {$a|$b}\n(first), [second]",
|
|
463
463
|
"expected": "first|second"
|
|
464
464
|
},
|
|
465
465
|
{
|
|
466
466
|
"id": 78,
|
|
467
|
-
"name": "
|
|
467
|
+
"name": "Basic pattern with literals",
|
|
468
468
|
"code": "pattern {match} {replace}\nmatch",
|
|
469
469
|
"expected": "replace"
|
|
470
470
|
},
|
|
471
471
|
{
|
|
472
472
|
"id": 79,
|
|
473
|
-
"name": "
|
|
473
|
+
"name": "Markdown heading example",
|
|
474
474
|
"code": "pattern {# $title} {<h1>$title</h1>}\n# Welcome",
|
|
475
475
|
"expected": "<h1>Welcome</h1>"
|
|
476
476
|
},
|
|
477
477
|
{
|
|
478
478
|
"id": 80,
|
|
479
|
-
"name": "
|
|
479
|
+
"name": "Multiple patterns cascade",
|
|
480
480
|
"code": "pattern {a} {b}\npattern {b} {c}\npattern {c} {d}\na",
|
|
481
481
|
"expected": "d"
|
|
482
482
|
},
|
|
483
483
|
{
|
|
484
484
|
"id": 81,
|
|
485
|
-
"name": "
|
|
485
|
+
"name": "Context basic",
|
|
486
486
|
"code": "context {\n pattern {$x} {<$x>}\n \n apple\n banana\n}",
|
|
487
|
-
"expected": "<apple>\n<banana>"
|
|
487
|
+
"expected": "<apple>\n <banana>"
|
|
488
488
|
},
|
|
489
489
|
{
|
|
490
490
|
"id": 82,
|
|
491
|
-
"name": "
|
|
491
|
+
"name": "$unique incremental",
|
|
492
492
|
"code": "pattern {item} {[$unique]item_$unique}\nitem\nitem\nitem",
|
|
493
493
|
"expected": "[0]item_0\n[1]item_1\n[2]item_2"
|
|
494
494
|
},
|
|
495
495
|
{
|
|
496
496
|
"id": 83,
|
|
497
|
-
"name": "
|
|
497
|
+
"name": "$unique same ID in replacement",
|
|
498
498
|
"code": "pattern {a} {$unique $unique}\na",
|
|
499
499
|
"expected": "0 0"
|
|
500
500
|
},
|
|
501
501
|
{
|
|
502
502
|
"id": 84,
|
|
503
|
-
"name": "
|
|
503
|
+
"name": "$match full match",
|
|
504
504
|
"code": "pattern {[$x]} {FOUND: $match}\n[data]",
|
|
505
505
|
"expected": "FOUND: [data]"
|
|
506
506
|
},
|
|
507
507
|
{
|
|
508
508
|
"id": 85,
|
|
509
|
-
"name": "
|
|
509
|
+
"name": "$prefix e $suffix",
|
|
510
510
|
"code": "pattern {world} {$prefix$suffix}hello world test",
|
|
511
511
|
"expected": "hello hello test test"
|
|
512
512
|
},
|
|
513
513
|
{
|
|
514
514
|
"id": 86,
|
|
515
|
-
"name": "
|
|
515
|
+
"name": "$clear remove before match",
|
|
516
516
|
"code": "pattern {SKIP $x} {$clear KEEP: $x}\nIGNORE_THIS SKIP keep_this",
|
|
517
517
|
"expected": "KEEP: keep_this"
|
|
518
518
|
},
|
|
519
519
|
{
|
|
520
520
|
"id": 87,
|
|
521
|
-
"name": "
|
|
521
|
+
"name": "$eval arithmetic multiplication",
|
|
522
522
|
"code": "pattern {$x} {$eval{return parseInt($x) * 2;}}\n5",
|
|
523
523
|
"expected": "10"
|
|
524
524
|
},
|
|
525
525
|
{
|
|
526
526
|
"id": 88,
|
|
527
|
-
"name": "
|
|
527
|
+
"name": "Markdown h1 and h2",
|
|
528
528
|
"code": "pattern {## $t} {<h2>$t</h2>}\npattern {# $t} {<h1>$t</h1>}\n# Title\n## Subtitle",
|
|
529
529
|
"expected": "<h1>Title</h1>\n<h2>Subtitle</h2>"
|
|
530
530
|
},
|
|
531
531
|
{
|
|
532
532
|
"id": 89,
|
|
533
|
-
"name": "
|
|
533
|
+
"name": "Markdown bold and italic",
|
|
534
534
|
"code": "pattern {**$t**} {<strong>$t</strong>}\npattern {*$t*} {<em>$t</em>}\n**bold** and *italic*",
|
|
535
535
|
"expected": "<strong>bold</strong> and <em>italic</em>"
|
|
536
536
|
},
|
|
537
537
|
{
|
|
538
538
|
"id": 90,
|
|
539
|
-
"name": "
|
|
539
|
+
"name": "Markdown list",
|
|
540
540
|
"code": "pattern {- $i} {<li>$i</li>}\n- item1\n- item2",
|
|
541
541
|
"expected": "<li>item1</li>\n<li>item2</li>"
|
|
542
542
|
},
|
|
543
543
|
{
|
|
544
544
|
"id": 91,
|
|
545
|
-
"name": "
|
|
545
|
+
"name": "CSV to JSON",
|
|
546
546
|
"code": "pattern {$a,$b,$c} {{ id: '$a', name: '$b', role: '$c' }}\n1,Alice,Engineer\n2,Bob,Designer",
|
|
547
547
|
"expected": "{ id: '1', name: 'Alice', role: 'Engineer' }\n{ id: '2', name: 'Bob', role: 'Designer' }"
|
|
548
548
|
},
|
|
549
549
|
{
|
|
550
550
|
"id": 92,
|
|
551
|
-
"name": "
|
|
551
|
+
"name": "Config parser",
|
|
552
552
|
"code": "pattern {$key = $value} {const $key = '$value';}\nhost = localhost\nport = 3000",
|
|
553
553
|
"expected": "const host = 'localhost';\nconst port = '3000';"
|
|
554
554
|
},
|
|
555
555
|
{
|
|
556
556
|
"id": 93,
|
|
557
|
-
"name": "
|
|
557
|
+
"name": "HTML generator",
|
|
558
558
|
"code": "pattern {$tag $content} {<$tag>$content</$tag>}\ndiv HelloWorld\nspan Test",
|
|
559
559
|
"expected": "<div>HelloWorld</div>\n<span>Test</span>"
|
|
560
560
|
},
|
|
561
561
|
{
|
|
562
562
|
"id": 94,
|
|
563
|
-
"name": "
|
|
563
|
+
"name": "Variable reuse in replacement",
|
|
564
564
|
"code": "pattern {$x} {$x:$x:$x}\ndata",
|
|
565
565
|
"expected": "data:data:data"
|
|
566
566
|
},
|
|
567
567
|
{
|
|
568
568
|
"id": 95,
|
|
569
|
-
"name": "
|
|
569
|
+
"name": "Literal dollar sign in replacement",
|
|
570
570
|
"code": "pattern {price} {Price: $50}\nprice",
|
|
571
571
|
"expected": "Price: $50"
|
|
572
572
|
},
|
|
573
573
|
{
|
|
574
574
|
"id": 96,
|
|
575
|
-
"name": "
|
|
575
|
+
"name": "Block with angle brackets nesting",
|
|
576
576
|
"code": "pattern {$block content {<}{>}} {CONTENT:$content}\nouter <inner <deep> more>",
|
|
577
577
|
"expected": "CONTENT:inner <deep> more"
|
|
578
578
|
},
|
|
579
579
|
{
|
|
580
580
|
"id": 97,
|
|
581
|
-
"name": "
|
|
581
|
+
"name": "Pattern with special regex characters",
|
|
582
582
|
"code": "pattern {a.*b} {MATCHED}\na.*b",
|
|
583
583
|
"expected": "MATCHED"
|
|
584
584
|
},
|
|
585
585
|
{
|
|
586
586
|
"id": 98,
|
|
587
|
-
"name": "
|
|
587
|
+
"name": "Multiple $eval operations",
|
|
588
588
|
"code": "pattern {add $a $b} {$eval{return parseInt($a) + parseInt($b)}}\nadd 15 25",
|
|
589
589
|
"expected": "40"
|
|
590
590
|
},
|
|
591
591
|
{
|
|
592
592
|
"id": 99,
|
|
593
|
-
"name": "
|
|
593
|
+
"name": "$eval with division and decimals",
|
|
594
594
|
"code": "pattern {div $a $b} {$eval{return $a / $b}}\ndiv 7 2",
|
|
595
595
|
"expected": "3.5"
|
|
596
596
|
},
|
|
597
597
|
{
|
|
598
598
|
"id": 100,
|
|
599
|
-
"name": "
|
|
599
|
+
"name": "Unicode characters support",
|
|
600
600
|
"code": "pattern {oi $name} {Olá $name!}\noi Mundo",
|
|
601
601
|
"expected": "Olá Mundo!"
|
|
602
602
|
},
|
|
603
603
|
{
|
|
604
604
|
"id": 101,
|
|
605
|
-
"name": "
|
|
605
|
+
"name": "Emoji support",
|
|
606
606
|
"code": "pattern {react $emoji} {Você reagiu: $emoji}\nreact 😊",
|
|
607
607
|
"expected": "Você reagiu: 😊"
|
|
608
608
|
},
|
|
609
609
|
{
|
|
610
610
|
"id": 102,
|
|
611
|
-
"name": "
|
|
611
|
+
"name": "Tab as flexible whitespace",
|
|
612
612
|
"code": "pattern {from$$to} {path: from -> to}\nfrom\tto",
|
|
613
613
|
"expected": "path: from -> to"
|
|
614
614
|
},
|
|
615
615
|
{
|
|
616
616
|
"id": 103,
|
|
617
|
-
"name": "
|
|
617
|
+
"name": "No match leaves input intact",
|
|
618
618
|
"code": "pattern {nomatch $x} {REPLACED}\nnothing matches here",
|
|
619
619
|
"expected": "nothing matches here"
|
|
620
620
|
},
|
|
621
621
|
{
|
|
622
622
|
"id": 104,
|
|
623
|
-
"name": "
|
|
623
|
+
"name": "Empty context is removed",
|
|
624
624
|
"code": "Start\ncontext {}End",
|
|
625
625
|
"expected": "Start\nEnd"
|
|
626
626
|
},
|
|
627
627
|
{
|
|
628
628
|
"id": 105,
|
|
629
|
-
"name": "
|
|
629
|
+
"name": "Block with pipe delimiters",
|
|
630
630
|
"code": "pattern {$block content {|}{|}} {PIPE[$content]}\n|value|",
|
|
631
631
|
"expected": "PIPE[value]"
|
|
632
632
|
},
|
|
633
633
|
{
|
|
634
634
|
"id": 106,
|
|
635
|
-
"name": "
|
|
635
|
+
"name": "Block with double quotes delimiter",
|
|
636
636
|
"code": "pattern {$block str {\"}{\"}} {STR[$str]}\n\"hello world\"",
|
|
637
637
|
"expected": "STR[hello world]"
|
|
638
638
|
},
|
|
639
639
|
{
|
|
640
640
|
"id": 107,
|
|
641
|
-
"name": "
|
|
641
|
+
"name": "Comma-separated pattern matching",
|
|
642
642
|
"code": "pattern {$a,$b,$c} {[$a] [$b] [$c]}\none,two,three",
|
|
643
643
|
"expected": "[one] [two] [three]"
|
|
644
644
|
},
|
|
645
645
|
{
|
|
646
646
|
"id": 108,
|
|
647
|
-
"name": "
|
|
647
|
+
"name": "Apostrophe in pattern literal",
|
|
648
648
|
"code": "pattern {It's $name} {Hello $name}\nIt's John",
|
|
649
649
|
"expected": "Hello John"
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
652
|
"id": 109,
|
|
653
|
-
"name": "
|
|
653
|
+
"name": "Math operation with $eval",
|
|
654
654
|
"code": "pattern {num $a} {$eval{return parseInt($a) + 1}}\nnum 999",
|
|
655
655
|
"expected": "1000"
|
|
656
656
|
},
|
|
657
657
|
{
|
|
658
658
|
"id": 110,
|
|
659
|
-
"name": "
|
|
659
|
+
"name": "Multi-character block delimiters",
|
|
660
660
|
"code": "pattern {$block code {open}{close}} {CODE[$code]}\nopenFunction()close",
|
|
661
661
|
"expected": "CODE[Function()]"
|
|
662
662
|
},
|
|
663
663
|
{
|
|
664
664
|
"id": 111,
|
|
665
|
-
"name": "
|
|
665
|
+
"name": "Pattern with dot literal",
|
|
666
666
|
"code": "pattern {$file.txt} {File: $file}\ndocument.txt",
|
|
667
667
|
"expected": "File: document"
|
|
668
668
|
},
|
|
669
669
|
{
|
|
670
670
|
"id": 112,
|
|
671
|
-
"name": "
|
|
671
|
+
"name": "Repeated global pattern matching",
|
|
672
672
|
"code": "pattern {x} {X}\nxxxxx",
|
|
673
673
|
"expected": "XXXXX"
|
|
674
674
|
},
|
|
675
675
|
{
|
|
676
676
|
"id": 113,
|
|
677
|
-
"name": "
|
|
677
|
+
"name": "Overlapping patterns cascade",
|
|
678
678
|
"code": "pattern {a} {A}\npattern {A} {B}\npattern {B} {C}\na",
|
|
679
679
|
"expected": "C"
|
|
680
680
|
},
|
|
681
681
|
{
|
|
682
682
|
"id": 114,
|
|
683
|
-
"name": "
|
|
683
|
+
"name": "Context with nested patterns",
|
|
684
684
|
"code": "context {\n pattern {$x} {\n<$x>}\napple\nbanana\ncherry\n}",
|
|
685
685
|
"expected": "<apple>\n<banana>\n<cherry>"
|
|
686
686
|
},
|
|
687
687
|
{
|
|
688
688
|
"id": 115,
|
|
689
|
-
"name": "
|
|
689
|
+
"name": "$eval with subtraction (negatives)",
|
|
690
690
|
"code": "pattern {calc $a $b} {$eval{return $a - $b}}\ncalc -5 -10",
|
|
691
691
|
"expected": "5"
|
|
692
692
|
},
|
|
693
693
|
{
|
|
694
694
|
"id": 116,
|
|
695
|
-
"name": "
|
|
695
|
+
"name": "Multiple spaces trim with flexible whitespace",
|
|
696
696
|
"code": "pattern {$$$word$$} {FOUND: $word}\n word ",
|
|
697
697
|
"expected": "FOUND: word"
|
|
698
698
|
},
|
|
699
699
|
{
|
|
700
700
|
"id": 117,
|
|
701
|
-
"name": "
|
|
701
|
+
"name": "Block captures parentheses with nesting",
|
|
702
702
|
"code": "pattern {$block content {(}{)}} {B[$content]}\n(a(b)c)",
|
|
703
703
|
"expected": "B[a(b)c]"
|
|
704
704
|
},
|
|
705
705
|
{
|
|
706
706
|
"id": 118,
|
|
707
|
-
"name": "
|
|
707
|
+
"name": "Arithmetic in config pattern",
|
|
708
708
|
"code": "pattern {$x + $y = $z} {$z is sum of $x and $y}\n5 + 3 = 8",
|
|
709
709
|
"expected": "8 is sum of 5 and 3"
|
|
710
710
|
},
|
|
711
711
|
{
|
|
712
712
|
"id": 119,
|
|
713
|
-
"name": "
|
|
713
|
+
"name": "Trailing punctuation in pattern",
|
|
714
714
|
"code": "pattern {$w,} {$w!}\nhello,",
|
|
715
715
|
"expected": "hello!"
|
|
716
716
|
}
|