Geoffrey Sneddon committed 0bde1f9

Add --w3c-compat-crazy-substitutions

  • Participants
  • Parent commits bdfdd3b

Comments (0)

Files changed (2)

 		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.")
+		default=False, dest="w3c_compat", help="Behave in a (mostly) compatible way to the W3C CSS WG's Postprocessor (this implies all of the other --w3c-compat options with the exception of --w3c-compat-crazy-substitution, as that is too crazy).")
 	parser.add_option("", "--w3c-compat-xref-elements", action="store_true",
 		default=False, dest="w3c_compat_xref_elements", help="Uses the same list of elements to look for cross-references in as the W3C CSS WG's Postprocessor, even when the elements shouldn't semantically be used for cross-reference terms.")
 	parser.add_option("", "--w3c-compat-class-toc", action="store_true",
 		default=False, dest="w3c_compat_class_toc", help="Add @class='toc' on every ol element in the table of contents (instead of only the root ol element).")
+	parser.add_option("", "--w3c-compat-substitutions", action="store_true",
+		default=False, dest="w3c_compat_substitutions", help="Do W3C specific substitutions.")
+	parser.add_option("", "--w3c-compat-crazy-substitutions", action="store_true",
+		default=False, dest="w3c_compat_crazy_substitutions", help="Do crazy W3C specific substitutions, which may cause unexpected behaviour (i.e., replacing random strings within the document with no special marker).")
 	parser.add_option("", "--profile", action="store_true",
 		default=False, dest="profile", help="Profile the execution of %prog.")

File specGen/processes/

 class sub(object):
 	"""Perform substitutions."""
-	def __init__(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, **kwargs):
-		if w3c_compat or w3c_compat_substitutions:
+	def __init__(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, w3c_compat_crazy_substitutions=False, **kwargs):
+		if w3c_compat or w3c_compat_substitutions or w3c_compat_crazy_substitutions:
 			self.w3c_status = self.getW3CStatus(ElementTree, **kwargs)
-		self.stringSubstitutions(ElementTree, w3c_compat, w3c_compat_substitutions, **kwargs)
-		self.commentSubstitutions(ElementTree, w3c_compat, w3c_compat_substitutions, **kwargs)
+		self.stringSubstitutions(ElementTree, w3c_compat, w3c_compat_substitutions, w3c_compat_crazy_substitutions, **kwargs)
+		self.commentSubstitutions(ElementTree, w3c_compat, w3c_compat_substitutions, w3c_compat_crazy_substitutions, **kwargs)
-	def stringSubstitutions(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, **kwargs):
+	def stringSubstitutions(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, w3c_compat_crazy_substitutions=False, **kwargs):
 		# Get doc_title from the title element
 			doc_title = utils.textContent(ElementTree.getroot().find("head").find("title"))
 		if w3c_compat or w3c_compat_substitutions:
 			# Get the right long status
 			doc_longstatus = longstatus_map[self.w3c_status]
+		if w3c_compat_crazy_substitutions:
 			# Get the right stylesheet
 			doc_w3c_stylesheet = "" + self.w3c_status
 		# And even more in compat. mode
 		if w3c_compat or w3c_compat_substitutions:
 			instance_string_subs += ((status, self.w3c_status, status_identifier),
-			                         (longstatus, doc_longstatus, longstatus_identifier),
-			                         (w3c_stylesheet, doc_w3c_stylesheet, w3c_stylesheet_identifier))
+			                         (longstatus, doc_longstatus, longstatus_identifier))
+		# And more that aren't even enabled by default in compat. mode
+		if w3c_compat_crazy_substitutions:
+			instance_string_subs += ((w3c_stylesheet, doc_w3c_stylesheet, w3c_stylesheet_identifier),)
 		for node in ElementTree.iter():
 			for regex, sub, identifier in instance_string_subs:
 					if identifier in value:
 						node.attrib[name] = regex.sub(sub, value)
-	def commentSubstitutions(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, **kwargs):
+	def commentSubstitutions(self, ElementTree, w3c_compat=False, w3c_compat_substitutions=False, w3c_compat_crazy_substitutions=False, **kwargs):
 		# Link
 		to_remove = set()
 		in_link = False