forked from Together-Java/ModernJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add String challenges from other PR + flags for turning on and off `v…
…oid main` (Together-Java#18) * Update division.md * Add basic feature flags impl * Integrate String challenges Fix script to not make an out.json Co-Authored-By: alphaBEE <[email protected]> * Remove "float point" * Fix mdlint complaints --------- Co-authored-by: alphaBEE <[email protected]>
- Loading branch information
1 parent
07635dd
commit 3232fb2
Showing
37 changed files
with
1,086 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import sys | ||
|
||
def preprocess_content(context, content): | ||
options = context.get("config", {}).get("preprocessor", {}).get("features", {}) | ||
newContent = [] | ||
skipping = False | ||
for line in content.splitlines(): | ||
if skipping: | ||
if line.strip() == "~ENDIF" or line.strip() == "~ ENDIF": | ||
skipping = False | ||
elif line.strip() == "~ELSE" or line.strip() == "~ ELSE": | ||
skipping = False | ||
elif line.strip().startswith("~IF ") or line.strip().startswith("~ IF "): | ||
if not options.get(line.split(" ", 2)[1].strip(), False): | ||
skipping = True | ||
elif line.strip() == "~ENDIF" or line.strip() == "~ ENDIF": | ||
continue | ||
elif line.strip() == "~ELSE" or line.strip() == "~ ELSE": | ||
skipping = True | ||
continue | ||
else: | ||
if options.get("simple_io", False) and options.get("toplevel_anonymous_class", False): | ||
newContent.append(line.replace("System.out.println", "println").replace("System.out.print", "print")) | ||
else: | ||
newContent.append(line) | ||
|
||
return "\n".join(newContent) | ||
|
||
def preprocess_section(context, section): | ||
if "Chapter" in section: | ||
section["Chapter"]["content"] = \ | ||
preprocess_content(context, section["Chapter"]["content"]) | ||
for sub_section in section["Chapter"].get("sub_items", []): | ||
preprocess_section(context, sub_section) | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) > 1: | ||
if sys.argv[1] == "supports": | ||
sys.exit(0) | ||
|
||
context, book = json.load(sys.stdin) | ||
|
||
for section in book["sections"]: | ||
preprocess_section(context, section) | ||
|
||
print(json.dumps(book)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Challenges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.