Geoffrey Sneddon  committed fed4c00

Add an option to allow duplicate xref terms.

  • Participants
  • Parent commits 1a22a4c
  • Branches default

Comments (0)

Files changed (2)

 	parser.add_option("", "--max-depth", action="store", type="int",
 		default=6, dest="max_depth", help="Lowest ranking header to number/insert into TOC.")
+	parser.add_option("", "--allow-duplicate-terms", action="store_true",
+		default=False, dest="allow_duplicate_terms", help="Allow multiple definitions of terms when cross-referencing (the last instance of the term is used when referencing it).")
 	parser.add_option("", "--w3c-compat", action="store_true",
 		default=False, dest="w3c_compat", help="Behave in a (mostly) compatible way to the W3C CSS WG's Postprocessor.")

File specGen/processes/

 		self.buildReferences(ElementTree, **kwargs)
 		self.addReferences(ElementTree, **kwargs)
-	def buildReferences(self, ElementTree, **kwargs):
+	def buildReferences(self, ElementTree, allow_duplicate_terms=False, **kwargs):
 		for dfn in ElementTree.iter("dfn"):
 			if dfn.get(u"title") is not None:
 				term = dfn.get(u"title")
 			term = term.strip(utils.spaceCharacters).lower()
 			if len(term) > 0:
-				if term in self.dfns:
+				if not allow_duplicate_terms and term in self.dfns:
 					raise DuplicateTermException, term
 				term = utils.spacesRegex.sub(" ", term)