From: Kenichi S. <Ken...@jp...> - 2002-08-22 00:27:17
|
Hi David, Thank you for the quick reply. In the message "Re: [Docutils-develop] Re: Strange --stylesheet handling..." on Wed, 21 Aug 2002 18:59:38 -0400, David Goodger <go...@us...> wrote: > You must be writing the HTML to a different disk than the one > containing the source file or stylesheet. Is this so? I hadn't > thought about that case. No, I put the source, the stylesheet and the target in the same disk and even in the same directory. > If that's not the case, please show us the command you use (and any > config files) which result in ``href="z:/default.css"``. Ok, I should have explained in more details. I attached (mount) a subdirectory of network drive as a virtual drive. For example, suppose I have a directory /tmp/docutils/tools on a samba server in which "test.txt" and "default.css" are there. Now I can mount the tools directory to Z: driver. Then the files are seen as Z:\test.txt and Z:\default.css respectively. Now, on Windows. bash> cd Z: bash> html.py test.txt test.html Then, the stylesheet specification becomes href="z:/default.css". REASON: I looked at the source code and found that * os.getcwd() returns the absolute path with the driver letter (e.g. "z:\\default.css") * docutils.utils.relative_uri() returns the absolute path if the common part of source and target is only the root directory. Therefore, 1. relative_uri("z:\\test.html". "z:\\default.css") => "z:/default.css" 2. relative_uri("z:\\abc\\test.html". "z:\\abc\\default.css") => "default.css" 3. relative_uri("z:\\abc\\efg\\test.html". "z:\\abc\\hij\\default.css") => "../hij/default.css" 4. relative_uri("z:\\abc\\test.html". "z:\\xyz\\default.css") => "z:/xyz/default.css" I believe we can implement relative_uri() so that it returns "default.css" for the case 1 and "../xyz/default.css" for the case 4. > > I understand the benefit of modifying the pathname to relative > > one, but it would be better if we had an option to turn it off. > I agree. I'm not certain of the best approach as yet. Here are the > latest notes: > Fix the absolute/relative path handling. > All references to files (stylesheet, source file [in footer], PEP > template) are interpreted relative to the current working directory, > and adjusted relative to the destination directory. For example:: > cd /work > html.py -s --stylesheet=default.css /src/test.txt /dst/text.html > This will interpret the stylesheet as "/work/default.css", so the > stylesheet link in the HTML (which is written to the /dst dir) will > read "../work/default.css", and the source link (-s option) will > read "../src/test.txt". > - Perhaps the current behavior should be optional > ("--relative-paths" or something). The default could be not to > process paths at all, just use them verbatim. > > - We could add an "--verbatim-paths" option, which indicates that > paths should not be modified at all. I didn't think about the other paths/URLs, but I would support the option 1 at least for stylesheet. I mean, by default, the string specified with --stylesheet option will appear in the <link rel="stylesheet" ... line. Then, if you specify --relative-paths (or --relative-stylesheet) option, the path is handled by utils.relative_uri() method. (Or, my problem will simply be solved by just fixing the above relative_uri() glitch) > - Use variant options, such as "--stylesheet-url=URL", which > wouldn't be interpreted as paths. Or leave "--stylesheet=URL" > uninterpreted, and add an interpreted "--stylesheet-path=PATH". This option might be confusing (I can imagine a post will come to the ML to ask the differences of these two :-) > Paths and URLs should be treated differently. Sometimes a relative > path can be treated as the equivalent of a relative URL, but that's > not the case for absolute paths/URLs. The "--pep-template" value is > *not* a URL, but a local file. "--stylesheet" could be either. > Source links (generated in the footer) may depend on how the HTML is > installed. I've been putting .html files in the same directories as > the source .txt files, but there are other ways to do it, and the > directory layout used at runtime may be different from the installed > layout. > I'd like to come up with a consistent, clean solution. Comments are > welcome. > 佐藤さん、フィードバックをいただいて、どうもありがとうございました。 Wow, it's in Japanese. いいえ、どういたしまして。 It's my pleasure. -- Kenichi SATO |