mirror of
https://github.com/emacs-twist/org-babel.git
synced 2025-03-05 16:27:07 +00:00
fix: Handle odd number argument lists
This commit is contained in:
parent
96d88bd7a4
commit
249dcb5a8e
1 changed files with 28 additions and 3 deletions
|
@ -1,11 +1,36 @@
|
||||||
with builtins;
|
with builtins;
|
||||||
let
|
let
|
||||||
|
takeWhile = p: xs:
|
||||||
|
if length xs == 0
|
||||||
|
then [ ]
|
||||||
|
else if p (head xs)
|
||||||
|
then [ (head xs) ] ++ takeWhile p (tail xs)
|
||||||
|
else [ ];
|
||||||
|
|
||||||
|
dropWhile = p: xs:
|
||||||
|
if length xs == 0
|
||||||
|
then [ ]
|
||||||
|
else if p (head xs)
|
||||||
|
then dropWhile p (tail xs)
|
||||||
|
else xs;
|
||||||
|
|
||||||
|
isKeyword = s: stringLength s > 0 && substring 0 1 s == ":";
|
||||||
|
|
||||||
|
notKeyword = s: !(isKeyword s);
|
||||||
|
|
||||||
|
toValue = xs:
|
||||||
|
if length xs == 0
|
||||||
|
then true
|
||||||
|
else if length xs == 1
|
||||||
|
then head xs
|
||||||
|
else xs;
|
||||||
|
|
||||||
listToAttrs = xs:
|
listToAttrs = xs:
|
||||||
if length xs == 0
|
if length xs == 0
|
||||||
then { }
|
then { }
|
||||||
else if length xs == 1
|
else {
|
||||||
then throw "parseParamsString: Found an odd number of items: ${head xs}"
|
${head xs} = toValue (takeWhile notKeyword (tail xs));
|
||||||
else { ${head xs} = elemAt xs 1; } // listToAttrs (tail (tail xs));
|
} // listToAttrs (dropWhile notKeyword (tail xs));
|
||||||
|
|
||||||
stripPat = "[[:space:]]+(.*)";
|
stripPat = "[[:space:]]+(.*)";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue