Discussion:
[Docutils-users] Replace with citation not as expected
Françoise Pinsard
2015-08-12 12:31:48 UTC
Permalink
Hi

Python 2.7.10 :: Anaconda 2.3.0 (x86_64)
rst2html.py (Docutils 0.12 [release], Python 2.7.10, on darwin)

Here an example to illustrate something strange when I put a citation
in a replace ...

tp.rst :

Citation references, like [CIT2002]_.

Another one |CIT2002_STYLE|.

.. [CIT2002] Author. 2002.

.. |CIT2002_STYLE| replace:: mystyle [CIT2002]

rst2html produce (div class document content) ::

<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle [CIT2002].</p>
<table class="docutils citation" frame="void" id="cit2002" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref"
href="#id1">[CIT2002]</a></td><td>Author. 2002.</td></tr>

while I expected ::

<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle <a class="citation-reference" href="#cit2002"
id="id1">[CIT2002]</a>.</p>

this problem was initially and indirectly raised using sphinxcontrib-bitex
see
https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/84

Regards
--
Françoise
David Goodger
2015-08-12 14:36:17 UTC
Permalink
In your example, try adding an underscore after the citation in the
substitution definition. Replace:

.. |CIT2002_STYLE| replace:: mystyle [CIT2002]

with:

.. |CIT2002_STYLE| replace:: mystyle [CIT2002]_

Without the trailing underscore, it's just bracketed text. The output
in the example looks right to me, based on the input.

DG


On Wed, Aug 12, 2015 at 7:31 AM, Françoise Pinsard
Post by Françoise Pinsard
Hi
Python 2.7.10 :: Anaconda 2.3.0 (x86_64)
rst2html.py (Docutils 0.12 [release], Python 2.7.10, on darwin)
Here an example to illustrate something strange when I put a citation
in a replace ...
Citation references, like [CIT2002]_.
Another one |CIT2002_STYLE|.
.. [CIT2002] Author. 2002.
.. |CIT2002_STYLE| replace:: mystyle [CIT2002]
<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle [CIT2002].</p>
<table class="docutils citation" frame="void" id="cit2002" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref"
href="#id1">[CIT2002]</a></td><td>Author. 2002.</td></tr>
<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle <a class="citation-reference" href="#cit2002"
id="id1">[CIT2002]</a>.</p>
this problem was initially and indirectly raised using sphinxcontrib-bitex
see
https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/84
Regards
--
Françoise
------------------------------------------------------------------------------
_______________________________________________
Docutils-users mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.
Françoise Pinsard
2015-08-12 15:28:12 UTC
Permalink
thanks for the hint but I tried and failed with
"Substitution definition contains illegal element"

here the full material (in/out).

$ cat tp.rst
.. rst2html.py tp.rst > tp.html
..

Citation references, like [CIT2002]_.

Another one |CIT2002_STYLE|.

.. |CIT2002_STYLE| replace:: mystyle [CIT2002]_

.. [CIT2002] Author. 2002.

$ rst2html.py tp.rst > tp.html
tp.rst:8: (ERROR/3) Substitution definition contains illegal element:

<citation_reference ids="id2" refname="cit2002">
CIT2002

.. |CIT2002_STYLE| replace:: mystyle [CIT2002]_

tp.rst:6: (ERROR/3) Undefined substitution referenced: "CIT2002_STYLE".

What am I missing ?
Post by David Goodger
In your example, try adding an underscore after the citation in the
.. |CIT2002_STYLE| replace:: mystyle [CIT2002]
.. |CIT2002_STYLE| replace:: mystyle [CIT2002]_
Without the trailing underscore, it's just bracketed text. The output
in the example looks right to me, based on the input.
DG
On Wed, Aug 12, 2015 at 7:31 AM, Françoise Pinsard
Post by Françoise Pinsard
Hi
Python 2.7.10 :: Anaconda 2.3.0 (x86_64)
rst2html.py (Docutils 0.12 [release], Python 2.7.10, on darwin)
Here an example to illustrate something strange when I put a citation
in a replace ...
Citation references, like [CIT2002]_.
Another one |CIT2002_STYLE|.
.. [CIT2002] Author. 2002.
.. |CIT2002_STYLE| replace:: mystyle [CIT2002]
<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle [CIT2002].</p>
<table class="docutils citation" frame="void" id="cit2002"
rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref"
href="#id1">[CIT2002]</a></td><td>Author. 2002.</td></tr>
<p>Citation references, like <a class="citation-reference"
href="#cit2002" id="id1">[CIT2002]</a>.</p>
<p>Another one mystyle <a class="citation-reference" href="#cit2002"
id="id1">[CIT2002]</a>.</p>
this problem was initially and indirectly raised using
sphinxcontrib-bitex
see
https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/84
Regards
--
Françoise
------------------------------------------------------------------------------
_______________________________________________
Docutils-users mailing list
https://lists.sourceforge.net/lists/listinfo/docutils-users
Please use "Reply All" to reply to the list.
--
Françoise
Loading...