### ----------------------------------------------------
### -- Markdown::Grammar
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/01-Parsing.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use lib '.';
use lib './lib';

use Markdown::Grammar;

#===========================================================

plan 17;

#-----------------------------------------------------------
## 1
#-----------------------------------------------------------
my $mtext1 = q:to/END/;
### Execution steps
END

ok md-parse($mtext1);

#-----------------------------------------------------------
## 2
#-----------------------------------------------------------
my $mtext2 = q:to/END/;
```perl6
my $obj = @dfTitanic ;
say "Titanic dimensions:", dimensions(@dfTitanic);
say to-pretty-table($obj.pick(7));
```
END

ok md-parse($mtext2);

#-----------------------------------------------------------
## 3
#-----------------------------------------------------------
my $mtext3 = q:to/END/;

```mathematica
x + y == Sqrt[Integrate[f[x], {x,0,30}]]
```

-----

## References

### Articles

[AA1] Anton Antonov,
["Introduction to data wrangling with Raku"](https://rakuforprediction.wordpress.com/2021/12/31/introduction-to-data-wrangling-with-raku/),
(2021),
[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).
END

ok md-parse($mtext3);

#-----------------------------------------------------------
## 4
#-----------------------------------------------------------

my $mtext4 = q:to/END/;

Here is a formula:

```mathematica
x + y == Sqrt[Integrate[f[x], {x,0,30}]]
```

Hopefully
you
got it.

No more formulas...

-----

## References

### Articles

[AA1] Anton Antonov,
["Introduction to data wrangling with Raku"](https://rakuforprediction.wordpress.com/2021/12/31/introduction-to-data-wrangling-with-raku/)
,
(2021),
[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).

[AA2] Anton Antonov,
["Увод в обработката на данни с Raku"](https://rakuforprediction.wordpress.com/2022/05/24/увод-в-обработката-на-данни-с-raku/)
,
(2022),
[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).

[AA3] Anton Antonov,
["Raku Text::CodeProcessing"](https://rakuforprediction.wordpress.com/2021/07/13/raku-textcodeprocessing/),
(2021),
[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).

[HW1] Hadley Wickham,
["The Split-Apply-Combine Strategy for Data Analysis"](https://www.jstatsoft.org/article/view/v040i01),
(2011),
[Journal of Statistical Software](https://www.jstatsoft.org/).

END

ok md-parse($mtext4);

#-----------------------------------------------------------
## 5
#-----------------------------------------------------------
my $mtext5 = q:to/END/;
### Execution steps

Copy the Titanic data into a "pipeline object" and show its dimensions and a sample of it:

```perl6
my $obj = @dfTitanic ;
say "Titanic dimensions:", dimensions(@dfTitanic);
say to-pretty-table($obj.pick(7));
```

Filter the data and show the number of rows in the result set:

```perl6
$obj = $obj.grep({ $_{"passengerSex"} eq "male" and $_{"passengerSurvival"} eq "died" or $_{"passengerSurvival"} eq "survived" }).Array ;
say $obj.elems;
```

Cross tabulate and show the result:
END

ok md-parse($mtext5);


#-----------------------------------------------------------
## 6
#-----------------------------------------------------------
my $mtext6 = q:to/END/;
### Monads

- LSAMon
- SMRMon
  - SBR too
- ClCon
END

ok md-parse($mtext6);

#-----------------------------------------------------------
## 7
#-----------------------------------------------------------
my $mtext7 = q:to/END/;
### Monads

1. LSAMon
2. SMRMon
  1. SBR too
3. ClCon
4. QRMon
END

ok md-parse($mtext7);

#-----------------------------------------------------------
## 8
#-----------------------------------------------------------
my $mtext8 = q:to/END/;
### Images

Here is the breakdown:

![](https://github.com/antononcube/PythonForPrediction-blog/raw/main/MarkdownDocuments/Diagrams/Breakdown-of-Python-people-and-projects/Breakdown-of-Python-people-and-projects-mind-map.pdf)

Here is the "Ocean" style version:

![Breakdown](https://github.com/antononcube/PythonForPrediction-blog/raw/main/MarkdownDocuments/Diagrams/Breakdown-of-Python-people-and-projects/Breakdown-of-Python-people-and-projects-mind-map-BW.png)
END

ok md-parse($mtext8);

#-----------------------------------------------------------
## 9
#-----------------------------------------------------------
my $mtext9 = q:to/END/;
### Images

Here see the linked PDF:

[![Breakdown](https://github.com/antononcube/PythonForPrediction-blog/raw/main/MarkdownDocuments/Diagrams/Breakdown-of-Python-people-and-projects/Breakdown-of-Python-people-and-projects-mind-map-BW.png)]((https://github.com/antononcube/PythonForPrediction-blog/raw/main/MarkdownDocuments/Diagrams/Breakdown-of-Python-people-and-projects/Breakdown-of-Python-people-and-projects-mind-map.pdf)
END

ok md-parse($mtext9);

#-----------------------------------------------------------
## 10
#-----------------------------------------------------------
my $mtext10 = q:to/END/;
Here is some code:

    obj = dfTitanic;
    obj = GroupBy[ obj, #["passengerSex"]& ];
    Echo[Map[ Length, obj], "counts:"]

More later...
END

ok md-parse($mtext10);

#-----------------------------------------------------------
## 11
#-----------------------------------------------------------
my $mtext11 = q:to/END/;
[enter image description here][1]

[![enter image description here][2]][2]

[1]: https://i.stack.imgur.com/cUxHw.png
[2]: https://i.stack.imgur.com/XWrJB.png
END

ok md-parse($mtext11);

#-----------------------------------------------------------
## 12
#-----------------------------------------------------------
my $mtext12 = q:to/END/;
They said:

> Select QR parameters to extract the "near constant y" points.
>
> Pick the *points* around produced regression quantile.
END

ok md-parse($mtext12);

#-----------------------------------------------------------
## 13
#-----------------------------------------------------------
my $mtext13 = q:to/END/;
They said:

**Select QR parameters to extract the "near constant y" points.**
*Pick the *points* around produced regression quantile.*

And more:

***Experiment!!***
END

ok md-parse($mtext13);

#-----------------------------------------------------------
## 14
#-----------------------------------------------------------
my $mtext14 = q:to/END/;
Here is a square of it:

```{perl6, eval=T}
$answer * $answer;
```

```{perl6, eval=T}
($answer ~ " ") x 5
```
END

ok md-parse($mtext14);

#-----------------------------------------------------------
## 15
#-----------------------------------------------------------
my $text15 = q:to/END/;
 | Company                      | Contact           | Country |
 |------------------------------|-------------------|---------|
 | Alfreds Futterkiste          | Maria Anders      | Germany |
 | Centro comercial Moctezuma   | Francisco Chang   | Mexico  |
 | Ernst Handel                 | Roland Mendel     | Austria |
 | Island Trading               | Helen Bennett     | UK      |
 | Laughing Bacchus Winecellars | Yoshi Tannamuri   | Canada  |
 | Magazzini Alimentari Riuniti | Giovanni Rovelli  | Italy   |
END

ok md-parse($text15, rule => 'md-table-block');


#-----------------------------------------------------------
## 16
#-----------------------------------------------------------
my $text16 = q:to/END/;
 | Company                      | Contact           | Country |
 | Alfreds Futterkiste          | Maria Anders      | Germany |
 | Centro comercial Moctezuma   | Francisco Chang   | Mexico  |
 | Ernst Handel                 | Roland Mendel     | Austria |
 | Island Trading               | Helen Bennett     | UK      |
 | Laughing Bacchus Winecellars | Yoshi Tannamuri   | Canada  |
 | Magazzini Alimentari Riuniti | Giovanni Rovelli  | Italy   |
END

ok md-parse($text16, rule => 'md-table-block');

#-----------------------------------------------------------
## 17
#-----------------------------------------------------------
my $mtext17 = q:to/END/;
**Remark:** For an example of a mature effort with the same mission (and naming, and design) see [SW1] and [WRIp1].
END

ok md-parse($mtext17.trim);

done-testing;


