|
From: Kenichi S. <Ken...@jp...> - 2002-08-21 09:57:44
|
Hi, > FROM: Adam Chodorowski > DATE: 08/14/2002 15:21:13 > SUBJECT: [Docutils-develop] Strange --stylesheet handling... > > Hi. > > I'm experiencing some strange handling of the --stylesheet option of the HTML > writer, which I use like the following:: > > stylesheet=aros.css > > But the generated HTML contains:: > > <link rel="stylesheet" href="../../docs/aros.css" type="text/css" /> > > And that is not at all what I specified! It should be noted that the source > file is in a different directory from the destination file, and that the > current directory is the source one. I think this is the problem: for some > reason the --stylesheet option is not taken verbatim, but is looked up > relative to the current directory and "corrected". I have the same problem and it is even worth for me because the driver letter (yes, I'm trying on Windows!) is put in front of the stylesheet path when it becomes the absolute one (e.g. href="z:/default.css"). This is not what I expected and totally useless if I want to publish the html pages through a web server. In my case, the trick found by Adam (specifying "../..." path) doesn't help either. 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. Regards, > This is totally useless for me, as I have separate build and source > directories. If this is a intended feature (I do see the usefullness of it > when building in a single directory), perhaps another option would be > apropriate. Something like --absolute-stylesheet perhaps? > > --- > Adam Chodorowski <<EMAIL: PROTECTED>> > > If studies were interesting, the world would come to a halt and nothing > would ever get done :) > -- James Kehl > > > ------------------------------------------------------- > This sf.net email is sponsored by: Dice - The leading online job board > for high-tech professionals. Search and apply for tech jobs today! > http://seeker.dice.com/seeker.epl?rel_code=31 > _______________________________________________ > Docutils-develop mailing list > <EMAIL: PROTECTED> > https://lists.sourceforge.net/lists/listinfo/docutils-develop -- Kenichi SATO |
|
From: David G. <go...@us...> - 2002-08-21 22:57:03
|
Kenichi Sato wrote:
> I have the same problem and it is even worth for me because the
> driver letter (yes, I'm trying on Windows!) is put in front of the
> stylesheet path when it becomes the absolute one
> (e.g. href="z:/default.css"). This is not what I expected and
> totally useless if I want to publish the html pages through a web
> server. In my case, the trick found by Adam (specifying "../..."
> path) doesn't help either.
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.
If that's not the case, please show us the command you use (and any
config files) which result in ``href="z:/default.css"``.
> 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.
- 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".
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.
佐藤さん、フィードバックをいただいて、どうもありがとうございました。
--
David Goodger <go...@us...> Open-source projects:
- Python Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)
- The Go Tools Project: http://gotools.sourceforge.net/
|
|
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
|
|
From: David G. <go...@us...> - 2002-08-22 02:44:04
|
Thanks for the detailed explanation. Kenichi Sato wrote: > 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. If you'd like to give it a try, patches are very welcome. > Wow, it's in Japanese. I lived in Gunma for 3 years and Tokyo for 4 years (Minato-ku, Shibaura). My wife is Japanese, so I get to practise. -- David Goodger <go...@us...> Open-source projects: - Python Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html) - The Go Tools Project: http://gotools.sourceforge.net/ |
|
From: Kenichi S. <Ken...@jp...> - 2002-08-22 12:23:32
|
In the message "Re: [Docutils-develop] Re: Strange --stylesheet handling..."
on Wed, 21 Aug 2002 22:46:44 -0400, David Goodger <go...@us...> wrote:
> Kenichi Sato wrote:
> > 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.
>
> If you'd like to give it a try, patches are very welcome.
Oops. Ok, I tried. The following patch seems working for me.
Index: utils.py
===================================================================
RCS file: /cvsroot/docutils/docutils/docutils/utils.py,v
retrieving revision 1.11
diff -c -r1.11 utils.py
*** utils.py 21 Aug 2002 02:43:46 -0000 1.11
--- utils.py 22 Aug 2002 12:04:24 -0000
***************
*** 364,370 ****
"""
source_parts = os.path.abspath(source).split(os.sep)
target_parts = os.path.abspath(target).split(os.sep)
! if source_parts[:2] != target_parts[:2]:
# Nothing in common between paths. Return absolute path.
return '/'.join(target_parts)
source_parts.reverse()
--- 364,370 ----
"""
source_parts = os.path.abspath(source).split(os.sep)
target_parts = os.path.abspath(target).split(os.sep)
! if source_parts[0] != target_parts[0]:
# Nothing in common between paths. Return absolute path.
return '/'.join(target_parts)
source_parts.reverse()
> > Wow, it's in Japanese.
>
> I lived in Gunma for 3 years and Tokyo for 4 years (Minato-ku,
> Shibaura). My wife is Japanese, so I get to practise.
I see.
--
Kenichi SATO
|
|
From: David G. <go...@us...> - 2002-08-23 02:27:33
|
Kenichi Sato wrote:
> The following patch seems working for me.
Thanks; it's checked in (with modifications). I still intend to fix the
command-line options somehow. I currently like this option best:
- Redefine "--stylesheet=URL" as an invariant, uninterpreted. Add
an interpreted "--stylesheet-path=PATH". Similarly for
"--pep-stylesheet". The -path variant would override.
--
David Goodger <go...@us...> Open-source projects:
- Python Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)
- The Go Tools Project: http://gotools.sourceforge.net/
|
|
From: David G. <go...@us...> - 2002-08-24 01:36:44
|
I've redefined "--stylesheet" as containing an invariant URL, used verbatim. Added "--stylesheet-path", interpreted w.r.t. the working directory. Similarly for "--pep-stylesheet" and "--pep-stylesheet-path". The snapshot is ready for download. -- David Goodger <go...@us...> Open-source projects: - Python Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html) - The Go Tools Project: http://gotools.sourceforge.net/ |
|
From: Adam C. <ad...@ch...> - 2002-08-24 02:08:25
|
On Fri, 23 Aug 2002 21:39:28 -0400 David Goodger
<go...@us...> wrote:
> I've redefined "--stylesheet" as containing an invariant URL, used
> verbatim. Added "--stylesheet-path", interpreted w.r.t. the working
> directory. Similarly for "--pep-stylesheet" and
> "--pep-stylesheet-path".
Great. :)
---
Adam Chodorowski <ad...@ch...>
Yes, 9 mm submachine guns with slower firing rates would reduce weight
problems, but it seems that real action heroes use Mac 10's, preferably one
in each hand. We can't help asking where the sidekicks are with wheelbarrows
to carry the ammo.
-- http://intuitor.com/moviephysics/
|
|
From: Kenichi S. <ks...@us...> - 2002-08-24 10:30:34
|
In the message "Re: [Docutils-develop] Re: Strange --stylesheet handling..."
on Fri, 23 Aug 2002 21:39:28 -0400, David Goodger <go...@us...> wrote:
> I've redefined "--stylesheet" as containing an invariant URL, used
> verbatim. Added "--stylesheet-path", interpreted w.r.t. the working
> directory. Similarly for "--pep-stylesheet" and
> "--pep-stylesheet-path".
> The snapshot is ready for download.
This change works fine for me too.
Thank you.
> --
> David Goodger <go...@us...> Open-source projects:
> - Python Docutils: http://docutils.sourceforge.net/
> (includes reStructuredText: http://docutils.sf.net/rst.html)
> - The Go Tools Project: http://gotools.sourceforge.net/
> -------------------------------------------------------
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone? Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> Docutils-develop mailing list
> Doc...@li...
> https://lists.sourceforge.net/lists/listinfo/docutils-develop
|