Make jl_to_json no longer strip puzzles, add strip-jl script

parent e7b78d8d
......@@ -22,7 +22,7 @@ out/manifest.json: $(shell find out/ -name "*.json" -not -name "manifest.json")
update-manifest $@
out/%.json: %.jpz
zstdcat $< | jl_to_json > $@
zstdcat $< | strip-jl | jl_to_json > $@
inplace-op:
zstdcat $(INPUT) | parallel -N100 --keep-order --pipe $(COMMAND) | pv -ls $$(zstdcat $(INPUT) | wc -l) | zstd -19 - -o $(TMP)
......
......@@ -23,23 +23,10 @@ if($argc !== 1) {
echo '[';
$first = true;
function trim_puzzle(&$step) {
if(is_array($step)) {
foreach($step[1] as &$s) trim_puzzle($s);
} else {
/* Leaf node */
assert(is_string($step));
$step = '';
}
}
while(($line = fgets(STDIN)) !== false) {
if(!$first) echo ',';
$first = false;
$puz = json_decode($line, true);
trim_puzzle($puz[1]);
echo json_encode($puz, JSON_UNESCAPED_SLASHES);
echo substr($line, 0, -1);
}
echo "]\n";
#!/usr/bin/env php
<?php
/* Copyright 2018 Romain "Artefact2" Dal Maso <artefact2@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if($argc !== 1) {
fprintf(STDERR, "Usage: %s < <jl>\n", $argv[0]);
die(1);
}
function trim_puzzle(&$step) {
if(is_array($step)) {
foreach($step[1] as &$s) trim_puzzle($s);
} else {
/* Leaf node */
assert(is_string($step));
$step = '';
}
}
while(($line = fgets(STDIN)) !== false) {
$puz = json_decode($line, true);
trim_puzzle($puz[1]);
echo json_encode($puz, JSON_UNESCAPED_SLASHES), "\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment