Skip to content

Commit c38aa36

Browse files
committed
feat:LaTeX conversion of a list of expressions.
1 parent 95177b4 commit c38aa36

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

lib/CortexJS.rakumod

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,24 @@ sub cortex-js-call($func, $expr) is export {
8585
return $ce.call($func, $expr);
8686
}
8787

88-
sub to-latex($expr) is export {
88+
sub to-latex($expr,
89+
:$sep is copy = Whatever,
90+
Bool:D :b(:$bracketed) = True,
91+
Str:D :$left-bracket = '$',
92+
Str:D :$right-bracket = '$'
93+
) is export {
8994
start-ce() without $ce;
90-
return $ce.to-latex($expr);
95+
96+
if $sep.isa(Whatever) { $sep = ', \: ' }
97+
die 'The argument $sep is expected to be a string or Whatever' unless $sep ~~ Str:D;
98+
99+
my $res = do if $expr ~~ (Array:D | List:D | Seq:D) && $expr.all ~~ (Array:D | List:D | Seq:D) {
100+
$expr.map({ $ce.to-latex($_) }).join($sep)
101+
} else {
102+
$ce.to-latex($expr)
103+
}
104+
105+
return $bracketed ?? $left-bracket ~ $res ~ $right-bracket !! $res;
91106
}
92107

93108
END {

0 commit comments

Comments
 (0)