On 2009-03-08, Dan Farina wrote:

> On Jan 22, 11:24 am, Georg Brandl <[email protected]> wrote:
>> Mike Lewis schrieb:

>> > Hi,

>> > I'm trying to convert some of our internal docs to RST. We have
>> > headings and other items that we want to cross reference such as
>> > "<foo>"

>> > If I do :ref:`<foo>` it doesn't understand it properly. :ref:`\<foo>`
>> > doesn't work either. It does work with a hyperlink though.

>> > How do I escape this? Or if it's a bug, I don't mind contributing a
>> > patch.

It is a Docutils feature: 

http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#reference-names
says: 

* whitespace is normalized (one or more spaces, horizontal or vertical
  tabs, newlines, carriage returns, or form feeds, are interpreted as a
  single space), and
* case is normalized (all alphabetic characters are converted to
  lowercase).

But there is an undocumented conversion too:

  <foo>
  =====
  
  forem fipsem

becomes

  <div class="section" id="foo">
  <h1>&lt;foo&gt;</h1>
  <p>forem fipsem</p>
  </div>


As the reference name is saved as id value in HTML, it cannot contain
<angle-bracketss> and other special chars. It is (most probably) converted
the same way as class names:

http://docutils.sourceforge.net/docs/ref/rst/directives.html#class


The names are transformed to conform to the regular expression
[a-z](-?[a-z0-9]+)* by converting

    * alphabetic characters to lowercase,
    * accented characters to the base character,
    * non-alphanumeric characters to hyphens,
    * consecutive hyphens into one hyphen.

There seems to be a non-documented behaviour:

    * non-alphanumeric characters are converted to hyphens if they occure
      in the middle of the name and stripped from the start or end.

So, _foo or :ref:`foo` should work (as long as there is no other
hyperlink targed called foo).

Günter


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to