Discussion:
[Docutils-users] background color experimentation...
Paul Flint
2017-02-10 12:53:41 UTC
Permalink
Greetings Earthlings (and anyone else :^),

The nice documentation page indicated that I should write to this list
when I am using the "raw" command too much. I have needed it twice so
here goes:

1. Easy one - make the background color of your choice:

.. raw:: html

<body style="background-color:#E6E6FA;">


2. Less easy one - Postprocessing the html to get the image to open in a
new
tab:

sphinx-build -b html ./ test ;
sed -i 's/><img/ target="_blank" ><img/g' test/index.html

Note sphinx is a lot of fun...

Kindest Regards,

☮ Paul Flint
(802) 479-2360
(802) 595-9365 Cell

/************************************
Based upon email reliability concerns,
please send an acknowledgment in response to this note.

Paul Flint, Director
Barre Open Systems Institute
17 Averill Street
Barre, VT
05641

http://www.bosivt.org
http://family.flint.com/flint
skype: flintinfotech
Work: (202) 537-0480

Consilium _
gratuitum .~. ASCII ribbon campaign ( )
valet /V\ against HTML e-mail X
quanti /( )\ www.asciiribbon.org / \
numerantur ^^-^^
David Goodger
2017-02-13 04:39:17 UTC
Permalink
Post by Paul Flint
Greetings Earthlings (and anyone else :^),
The nice documentation page indicated that I should write to this list when
.. raw:: html
<body style="background-color:#E6E6FA;">
You don't need to use the "raw" directive for this. This can be done
easily via a stylesheet:
http://docutils.sourceforge.net/docs/howto/html-stylesheets.html
Post by Paul Flint
2. Less easy one - Postprocessing the html to get the image to open in a new
This has been on the to-do list for a long time, but (a) it's not a
high-frequency request (yours is the first I can recall), and (b) no
obviously correct solution has been proposed. The to-do list has a
proposal to emulate the MoinMoin wiki's use of "^" as a prefix for
this purpose.

If you want this for every image in all of some subset of your
documents, you could create a custom Writer deriving from the HTML
Writer you already use (or its Sphinx equivalent).
Post by Paul Flint
Note sphinx is a lot of fun...
Maybe tell the Sphinx folks that? This is Docutils/reStructuredText,
which Sphinx does use, but they aren't the same thing :-)

David Goodger
<http://python.net/~goodger>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Paul Flint
2017-02-13 14:12:34 UTC
Permalink
Greetings David Goodger,

First, thanks for the response. Up here in the North Country one of our
hobbies is staying under-the-radar, and thus we live in cold, dark,
ignorance most of the time...

In your kind response, you make some interesting points. I will respond
below.
Post by David Goodger
Post by Paul Flint
.. raw:: html
<body style="background-color:#E6E6FA;">
You don't need to use the "raw" directive for this. This can be done
http://docutils.sourceforge.net/docs/howto/html-stylesheets.html
Very cool. For openers, I did not know about rst2html.py - Thanks. BTW
nice style in the python code! I could learn a thing or two from you.

That said, my use case is that I have about 100 DVDs (Source Linux Format)
that I am putting up on the web. Each DVD has a page that shows the
original front and back cover. What I wanted was that each of these pages
display in a color of the season. My idea was to put together these DVD
"base pages" using a bash script (I am a registered bashist. See
http://visualbash.org :^) and cycling through some seasonally appropriate
pastel colors to help the user differentiate between the various DVDs.

The ".. raw" directive was wildly successful in allowing this page-by-page
transition. Could I advantage myself with the css approach?

This experience has led me to the very disturbing conclusion that you
could (and maybe should) write all web pages in reStructuredText. Should
I seek professional help?
Post by David Goodger
Post by Paul Flint
2. Less easy one - Postprocessing the html to get the image to open in a new
This has been on the to-do list for a long time, but (a) it's not a
high-frequency request (yours is the first I can recall), and (b) no
obviously correct solution has been proposed. The to-do list has a
proposal to emulate the MoinMoin wiki's use of "^" as a prefix for
this purpose.
Interesting bit of extended notation. I need to think if this would
work...
Post by David Goodger
If you want this for every image in all of some subset of your
documents, you could create a custom Writer deriving from the HTML
Writer you already use (or its Sphinx equivalent).
My fix for this was to go directly to the resultant html and patch it
there:

<start code>
sphinx-build -b html ./ test ;
sed -i 's/><img/ target="_blank" ><img/g' test/index.html
<end code>

(Note what we bashists lack in finesse we make up with gusto... :^)

Obviously the "MoinMoin" notation would go a step towards a standard wiki
markup language, and why not extend ourselves into this maelstrom?
Post by David Goodger
Post by Paul Flint
Note sphinx is a lot of fun...
Maybe tell the Sphinx folks that? This is Docutils/reStructuredText,
which Sphinx does use, but they aren't the same thing :-)
Gotcha. The most fun was getting the reStructuredText editor "enki" to
run under Ubuntu 16.04. I need to figure out how to communicate my
zaniness to the Sphinx community...
Post by David Goodger
David Goodger
<http://python.net/~goodger>
Finally thanks for the Venn diagram, and I expect we should get together
in Portland to rub antennae... Are you up in Montreal? I love that city!

Kindest Regards,


☮ Paul Flint
(802) 479-2360 Home
(802) 595-9365 Cell

/************************************
Based upon email reliability concerns,
please send an acknowledgement in response to this note.

Paul Flint
17 Averill Street
Barre, VT
05641
David Goodger
2017-02-13 17:49:49 UTC
Permalink
Post by Paul Flint
Greetings David Goodger,
First, thanks for the response. Up here in the North Country one of our
hobbies is staying under-the-radar, and thus we live in cold, dark,
ignorance most of the time...
In your kind response, you make some interesting points. I will respond
below.
Post by David Goodger
Post by Paul Flint
.. raw:: html
<body style="background-color:#E6E6FA;">
You don't need to use the "raw" directive for this. This can be done
http://docutils.sourceforge.net/docs/howto/html-stylesheets.html
Very cool. For openers, I did not know about rst2html.py - Thanks. BTW
nice style in the python code! I could learn a thing or two from you.
That said, my use case is that I have about 100 DVDs (Source Linux Format)
that I am putting up on the web. Each DVD has a page that shows the original
front and back cover. What I wanted was that each of these pages display in
a color of the season. My idea was to put together these DVD "base pages"
using a bash script (I am a registered bashist. See http://visualbash.org
:^) and cycling through some seasonally appropriate pastel colors to help
the user differentiate between the various DVDs.
The ".. raw" directive was wildly successful in allowing this page-by-page
transition. Could I advantage myself with the css approach?
You'd have to change the CSS for each page.

I'm not sure how your raw hack works, since you should end up with
multiple <body> elements in your output HTML, unless you also changed
the template. This might render in browsers but it's not valid HTML.
Post by Paul Flint
This experience has led me to the very disturbing conclusion that you could
(and maybe should) write all web pages in reStructuredText. Should I seek
professional help?
No, I don't think so. :-) That's what I do as well, and what many of us do.
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
2. Less easy one - Postprocessing the html to get the image to open in a new
This has been on the to-do list for a long time, but (a) it's not a
high-frequency request (yours is the first I can recall), and (b) no
obviously correct solution has been proposed. The to-do list has a
proposal to emulate the MoinMoin wiki's use of "^" as a prefix for
this purpose.
Interesting bit of extended notation. I need to think if this would work...
Post by David Goodger
If you want this for every image in all of some subset of your
documents, you could create a custom Writer deriving from the HTML
Writer you already use (or its Sphinx equivalent).
<start code>
sphinx-build -b html ./ test ;
sed -i 's/><img/ target="_blank" ><img/g' test/index.html
<end code>
That's very risky. It's adding “ target="_blank"” to any tag
immediately before an <img> tag. Are you sure that they are all <a>
tags, and always will be?
Post by Paul Flint
(Note what we bashists lack in finesse we make up with gusto... :^)
Reminds me of:

Some people, when confronted with a problem, think "I know, I'll
use regular expressions." Now they have two problems.

— Jamie Zawinski

The same could be said about sed & awk.
Post by Paul Flint
Obviously the "MoinMoin" notation would go a step towards a standard wiki
markup language, and why not extend ourselves into this maelstrom?
I'm not following you, and I'm a native English speaker. Many on this
list are not. Repeat in plainer language please?
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
Note sphinx is a lot of fun...
Maybe tell the Sphinx folks that? This is Docutils/reStructuredText,
which Sphinx does use, but they aren't the same thing :-)
Gotcha. The most fun was getting the reStructuredText editor "enki" to run
under Ubuntu 16.04. I need to figure out how to communicate my zaniness to
the Sphinx community...
Post by David Goodger
David Goodger
<http://python.net/~goodger>
Finally thanks for the Venn diagram, and I expect we should get together in
Portland to rub antennae... Are you up in Montreal? I love that city!
I used to live near Montreal, now I live in a suburb of the Twin
Cities of Minnesota. It's only slightly warmer here.

David Goodger
<http://python.net/~goodger>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply
Paul Flint
2017-02-13 18:14:30 UTC
Permalink
Greetings David Goodger,
Post by David Goodger
Post by Paul Flint
In your kind response, you make some interesting points. I will respond
below.
Post by David Goodger
Post by Paul Flint
.. raw:: html
<body style="background-color:#E6E6FA;">
You don't need to use the "raw" directive for this. This can be done
http://docutils.sourceforge.net/docs/howto/html-stylesheets.html
Very cool. For openers, I did not know about rst2html.py - Thanks. BTW
nice style in the python code! I could learn a thing or two from you.
That said, my use case is that I have about 100 DVDs (Source Linux Format)
that I am putting up on the web. Each DVD has a page that shows the original
front and back cover. What I wanted was that each of these pages display in
a color of the season. My idea was to put together these DVD "base pages"
using a bash script (I am a registered bashist. See http://visualbash.org
:^) and cycling through some seasonally appropriate pastel colors to help
the user differentiate between the various DVDs.
The ".. raw" directive was wildly successful in allowing this page-by-page
transition. Could I advantage myself with the css approach?
You'd have to change the CSS for each page.
Actually what I got to thinking about was a way to add a
reStructuredText element which would query the css for the appropriate
background shade...

For example:

SEASON BACKGROUND
spring = a warming color
summer = a warm color
fall = a cooling color
winter = a cool colr

The Vermont version would of course, also contain:
Mud Season
Black Fly Season
Post by David Goodger
I'm not sure how your raw hack works, since you should end up with
multiple <body> elements in your output HTML, unless you also changed
the template. This might render in browsers but it's not valid HTML.
Na, I checked. It over-rode .../_static/alabaster.css
Post by David Goodger
Post by Paul Flint
This experience has led me to the very disturbing conclusion that you could
(and maybe should) write all web pages in reStructuredText. Should I seek
professional help?
No, I don't think so. :-) That's what I do as well, and what many of us do.
Hm...
Post by David Goodger
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
2. Less easy one - Postprocessing the html to get the image to open in a
This has been on the to-do list for a long time, but (a) it's not a
high-frequency request (yours is the first I can recall), and (b) no
obviously correct solution has been proposed. The to-do list has a
proposal to emulate the MoinMoin wiki's use of "^" as a prefix for
this purpose.
Interesting bit of extended notation. I need to think if this would work...
Post by David Goodger
If you want this for every image in all of some subset of your
documents, you could create a custom Writer deriving from the HTML
Writer you already use (or its Sphinx equivalent).
<start code>
sphinx-build -b html ./ test ;
sed -i 's/><img/ target="_blank" ><img/g' test/index.html
<end code>
That's very risky. It's adding “ target="_blank"” to any tag
immediately before an <img> tag. Are you sure that they are all <a>
tags, and always will be?
I go away with it... but I was not happy with this monster.
Post by David Goodger
Post by Paul Flint
(Note what we bashists lack in finesse we make up with gusto... :^)
Some people, when confronted with a problem, think "I know, I'll
use regular expressions." Now they have two problems.
— Jamie Zawinski
The same could be said about sed & awk.
I shall cherish this and use it with attribution not retribution...
Post by David Goodger
Post by Paul Flint
Obviously the "MoinMoin" notation would go a step towards a standard wiki
markup language, and why not extend ourselves into this maelstrom?
I'm not following you, and I'm a native English speaker. Many on this
list are not. Repeat in plainer language please?
Indeed I once was before I started to program. MoinMoin being of German
provenance, it no doubt contains it's own markup syntax. How much to we
adopt? That is my point here.
Post by David Goodger
Post by Paul Flint
Finally thanks for the Venn diagram, and I expect we should get together in
Portland to rub antennae... Are you up in Montreal? I love that city!
I used to live near Montreal, now I live in a suburb of the Twin
Cities of Minnesota. It's only slightly warmer here.
Nice, and...


Kindest Regards,



☮ Paul Flint
(802) 479-2360 Home
(802) 595-9365 Cell

/************************************
Based upon email reliability concerns,
please send an acknowledgement in response to this note.

Paul Flint
17 Averill Street
Barre, VT
05641
Guenter Milde
2017-02-14 13:30:52 UTC
Permalink
...
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
.. raw:: html
<body style="background-color:#E6E6FA;">
You don't need to use the "raw" directive for this. This can be done
http://docutils.sourceforge.net/docs/howto/html-stylesheets.html
...
Post by Paul Flint
Post by David Goodger
Post by Paul Flint
That said, my use case is that I have about 100 DVDs (Source Linux Format)
that I am putting up on the web. Each DVD has a page that shows the original
front and back cover. What I wanted was that each of these pages display in
a color of the season. My idea was to put together these DVD "base pages"
using a bash script (I am a registered bashist. See http://visualbash.org
:^) and cycling through some seasonally appropriate pastel colors to help
the user differentiate between the various DVDs.
The ".. raw" directive was wildly successful in allowing this page-by-page
transition. Could I advantage myself with the css approach?
You'd have to change the CSS for each page.
Actually what I got to thinking about was a way to add a
reStructuredText element which would query the css for the appropriate
background shade...
SEASON BACKGROUND
spring = a warming color
summer = a warm color
fall = a cooling color
winter = a cool colr
Use classes:

The custom CSS sheet defines rules like::

.figure.spring { background-color:#E6E6FA; }

(adapt the selector to the element you want to give the background).
and in bash script don't insert raw HTML but class values.

Günter

Continue reading on narkive:
Loading...