mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make token references work as hyperlinks again in LaTeX output.
This commit is contained in:
parent
9bd6d74109
commit
d7c021bc5f
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
||||
Release 1.0.7 (in development)
|
||||
==============================
|
||||
|
||||
* Make token references work as hyperlinks again in LaTeX output.
|
||||
|
||||
* #572: Show warnings by default when reference labels cannot be
|
||||
found.
|
||||
|
||||
|
@ -46,10 +46,6 @@ class LaTeXBuilder(Builder):
|
||||
return 'all documents' # for now
|
||||
|
||||
def get_target_uri(self, docname, typ=None):
|
||||
if typ == 'token':
|
||||
# token references are always inside production lists and must be
|
||||
# replaced by \token{} in LaTeX
|
||||
return '@token'
|
||||
if docname not in self.docnames:
|
||||
raise NoUri
|
||||
else:
|
||||
|
@ -237,21 +237,12 @@
|
||||
\addtolength{\py@argswidth}{\linewidth}%
|
||||
\item[#1\code{(}\py@sigparams{#2}{#3}]}
|
||||
|
||||
% This version is being checked in for the historical record; it shows
|
||||
% how I've managed to get some aspects of this to work. It will not
|
||||
% be used in practice, so a subsequent revision will change things
|
||||
% again. This version has problems, but shows how to do something
|
||||
% that proved more tedious than I'd expected, so I don't want to lose
|
||||
% the example completely.
|
||||
% Production lists
|
||||
%
|
||||
\newcommand{\grammartoken}[1]{\texttt{#1}}
|
||||
\newenvironment{productionlist}[1][\@undefined]{
|
||||
\def\optional##1{{\Large[}##1{\Large]}}
|
||||
\def\production##1##2{\hypertarget{grammar-token-##1}{}%
|
||||
\code{##1}&::=&\code{##2}\\}
|
||||
\def\productioncont##1{& &\code{##1}\\}
|
||||
\def\token##1{##1}
|
||||
\let\grammartoken=\token
|
||||
\newenvironment{productionlist}{
|
||||
% \def\optional##1{{\Large[}##1{\Large]}}
|
||||
\def\production##1##2{\\\code{##1}&::=&\code{##2}}
|
||||
\def\productioncont##1{\\& &\code{##1}}
|
||||
\parindent=2em
|
||||
\indent
|
||||
\begin{tabular}{lcl}
|
||||
|
@ -266,10 +266,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
'\\label{%s}' % self.idescape(id)
|
||||
|
||||
def hyperlink(self, id):
|
||||
return '{\\hyperref[%s]{' % (self.idescape(id))
|
||||
return '{\\hyperref[%s]{' % self.idescape(id)
|
||||
|
||||
def hyperpageref(self, id):
|
||||
return '\\autopageref*{%s}' % (self.idescape(id))
|
||||
return '\\autopageref*{%s}' % self.idescape(id)
|
||||
|
||||
def idescape(self, id):
|
||||
return str(unicode(id).translate(tex_replace_map))
|
||||
@ -422,8 +422,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_production(self, node):
|
||||
if node['tokenname']:
|
||||
self.body.append('\\production{%s}{' %
|
||||
self.encode(node['tokenname']))
|
||||
tn = node['tokenname']
|
||||
self.body.append(self.hypertarget('grammar-token-' + tn))
|
||||
self.body.append('\\production{%s}{' % self.encode(tn))
|
||||
else:
|
||||
self.body.append('\\productioncont{')
|
||||
def depart_production(self, node):
|
||||
@ -1133,12 +1134,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.context.append('}} (%s)' % self.hyperpageref(id))
|
||||
else:
|
||||
self.context.append('}}')
|
||||
elif uri.startswith('@token'):
|
||||
if self.in_production_list:
|
||||
self.body.append('\\token{')
|
||||
else:
|
||||
self.body.append('\\grammartoken{')
|
||||
self.context.append('}')
|
||||
else:
|
||||
self.builder.warn('unusable reference target found: %s' % uri,
|
||||
(self.curfilestack[-1], node.line))
|
||||
|
Loading…
Reference in New Issue
Block a user