Edit "slideshow" script

Csaba Henk 2020-03-28 22:06:52 +01:00
parent 5cdd802b1f
commit 2d5decf66d
1 changed files with 11 additions and 5 deletions

@ -44,8 +44,10 @@ alcs0 = $<.each_with_object({y:false, t:[]}) { |l,ah|
ah[:y] and l.strip=="```" and (ah[:y]=false;next) ah[:y] and l.strip=="```" and (ah[:y]=false;next)
ah[:y] and (ah[:t].last||[]) << l ah[:y] and (ah[:t].last||[]) << l
}[:t] }[:t]
alcs1=alcs0.each_with_object({}) {|e,ah| (e[1..-1].grep(/\A\s*[^#]/)[0]||"") =~ /colors:/ and ah[e[0]]=YAML.load(e[1..-1].join)["colors"]} alcs1 = alcs0.each_with_object({}) { |e,ah|
alcs2={"schemes"=>alcs1,"scheme_toc"=> alcs1.dup} (e[1..-1].grep(/\A\s*[^#]/)[0]||"") =~ /colors:/ and ah[e[0]]=YAML.load(e[1..-1].join)["colors"]
}
alcs2 = {"schemes"=> alcs1, "scheme_toc"=> alcs1.dup}
puts alcs2.to_yaml puts alcs2.to_yaml
``` ```
@ -83,7 +85,11 @@ Or, saving the output as _alcs.yml_, you can run a "slideshow" of themes as foll
ruby -ryaml -e 'puts YAML.load($<)["schemes"].keys' "$cnf" | cat -n | \ ruby -ryaml -e 'puts YAML.load($<)["schemes"].keys' "$cnf" | cat -n | \
while read j s; do while read j s; do
echo $j. $s echo $j. $s
ruby -ryaml -i -e 'sch=$*.pop; cnf=YAML.load $<; cnf["colors"]=cnf["schemes"][sch]; puts cnf.to_yaml' "$cnf" "$s" ruby -ryaml -i -e '
sch=$*.pop
cnf=YAML.load $<
cnf["colors"]=cnf["schemes"][sch]
puts cnf.to_yaml' "$cnf" "$s"
read < $tty read < $tty
done done
``` ```