From: <eng...@ss...> - 2003-03-13 07:50:56
|
On Wed, 12 Mar 2003, David Goodger wrote: > Please either keep discussions entirely on-list, or entirely off (if you're > collaborating on a proposal to be posted later). This thread is very > confusing with most of it missing. Also, it helps to reduce duplication if > we're all privy to the entire discussion. sorry, i thought it was clear enough. adam ---- > I would like to write a transform that changes relative, external > references (and keeps all other as they are) in a certain way depending > on what writer is used (or, depending on a option passed if that's > easier). > > The only thing I really want to do is to append ".html" or ".pdf" to the > reference, nothing else. I currently don't care about being able to reach > references "inside" the other document, just being able to reach the > *document* as a whole is enough. > > I don't really know. This issue needs to be thought about some more, and I > don't have time for that right now. :-/ What I've done for my particular > application is to simply patch the HTML writer to mangle the references if > they are relative and don't end with '.html' or '/'. my proposal is -------------- * have a master_reference_transformer (MRT), doing it. * in this case the writer would call MRT.transform(writer,this_reference) to get it modified. By putting it in the writer, the writer can decide not to call this for internally generated references. * the MRT transformationw are taken from docutils.conf. :: def MRT.transform(self,writer,ref): for r in self.replacements[writer]: new_ref = r.transform(ref) if not new_ref == ref: return new_ref return ref def r.transform(self,ref): if self.search_startswith == "": # relative reference: if ref.startswith("/") or ref.find(":"): return ref elif not ref.startswith(self.search): return ref # MAYBE add a search_extension. replace startswith: e.g. relative urls with absolute. replace the file extension: e.g. .html with pdf or png with eps. where, if it is accepted,should the master_reference_transformer ? * docutils/transform as it is named so. * docutils/writers where it is used. * docutils/ frontend.py holds the COnfigParser. a better name for it ? transmogrifier ? -- BINGO: professional content quickly maintaned --- Engelbert Gruber -------+ SSG Fintl,Gruber,Lassnig / A6410 Telfs Untermarkt 9 / Tel. ++43-5262-64727 ----+ |