Tightened up how CG ruleid's are extracted from the index.

master
Pacman Ghost 3 years ago
parent 45c6c5e48f
commit 0aff6273e7
  1. 18
      asl_rulebook2/extract/data/index-fixups.json
  2. 20
      asl_rulebook2/extract/index.py
  3. 2
      bin/add_pdf_dests.py

@ -66,10 +66,7 @@
"End of Scenario": {
"replace": [
[ "[in ABtF: R9.4 CG4]", "[in ABtF: R9.4, CG4]" ],
[ "[in KGP: P8.4 CG23]", "[in KGP: P8.4, CG23]" ],
[ "[in PB: Q9.4 CG19 (-1 drm for any Night Scenario and +1 drm for Day II scenario: Turn Record Track)]", "[in PB (-1 drm for any Night Scenario and +1 drm for Day II scenario: Turn Record Track): Q9.4, CG19]" ],
[ "[in RB: O11.4 CG4]", "[in RB: O11.4, CG4]" ]
[ "[in PB: Q9.4 CG19 (-1 drm for any Night Scenario and +1 drm for Day II scenario: Turn Record Track)]", "[in PB (-1 drm for any Night Scenario and +1 drm for Day II scenario: Turn Record Track): Q9.4 CG19]" ]
]
},
@ -196,13 +193,6 @@
]
},
"Radio": {
"replace": [
[ "[in KGP: P8.4 CG15]", "[in KGP: P8.4, CG15]" ],
[ "[in RB: O11.4 CG6]", "[in RB: O11.4, CG6]" ]
]
},
"Range": {
"replace": [
[ "see Firing Within Hex", "A7.21" ]
@ -215,6 +205,12 @@
]
},
"Reinforcements": {
"replace": [
[ "P8.4, CG7", "P8.4 CG7" ]
]
},
"Rubble": {
"replace": [
[ "; Stone Blaze:", "] [RePh, Stone Blaze:" ]

@ -198,6 +198,22 @@ class ExtractIndex( ExtractBase ):
def _process_content( self ):
"""Extract information out of the index entries into a structured form."""
def fixup_ruleid( ruleid ):
# FUDGE! The index often refers to the same rule as e.g. "O11.4 CG3" and "OCG3" :-/
# We translate the former into the latter.
if ruleid.startswith( "O11.4 CG" ):
return "O" + ruleid[6:] # nb: Red Barricades
elif ruleid.startswith( "P8.4 CG" ):
return "P" + ruleid[5:] # nb: Kampfgruppe Peiper
elif ruleid.startswith( "Q9.4 CG" ):
return "Q" + ruleid[5:] # nb: Pegasus Bridge
elif ruleid.startswith( "R9.4 CG" ):
return "R" + ruleid[5:] # nb: A Bridge Too Far
elif ruleid.startswith( "T15.4 CG" ):
return "T" + ruleid[6:] # nb: Blood Reef Tarawa
else:
return ruleid
for index_entry in self.index_entries:
# initialize
@ -244,7 +260,7 @@ class ExtractIndex( ExtractBase ):
else:
break
if ruleids:
index_entry[ "ruleids" ] = ruleids
index_entry[ "ruleids" ] = [ fixup_ruleid( r ) for r in ruleids ]
# extract any ruleref's
rulerefs = []
@ -256,7 +272,7 @@ class ExtractIndex( ExtractBase ):
pos = val.rfind( ":" )
if pos > 0:
vals = re.split( "[;,]", val[pos+1:] )
ruleids = [ v.strip() for v in vals ]
ruleids = [ fixup_ruleid( v.strip() ) for v in vals ]
val = val[:pos].strip()
else:
ruleids = None

@ -45,7 +45,7 @@ def main( pdf_file, title, targets_fname, yoffset, output_fname, gs_path ):
if isinstance( ypos, int ):
ypos += yoffset
if " " in ruleid:
# NOTE: We are supposed to be able to quote things using parenthese (e.g. "(foo bar)"
# NOTE: We are supposed to be able to quote things using parentheses (e.g. "(foo bar)"
# but it doesn't seem to work here :-(
raise RuntimeError( "PDF destinations cannot have spaces." )
print( "[ /Dest /{} /Page {} /View [/XYZ {} {}] /DEST pdfmark".format(

Loading…
Cancel
Save