Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upparsed-literal output #2167
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreacassioli
commented
Mar 19, 2016
|
Am I the only one experiencing this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pburdine
May 14, 2016
I see the same thing.
For example:
.. parsed-literal::
# cd *someDirectory*
In other places I used rst replacements like:
.. parsed-literal::
# cd |directory|
In the first example, in the PDF output it shows up like a normal code block (black border, syntax highlighting, etc), but the second example doesn't
In the .tex file for the marked up parsed-literal it looks like:
\begin{Verbatim}[commandchars=\\\{\}]
...content here...
\end{Verbatim}
But in the parsed-literal with the substitution, it renders like:
\begin{alltt}
...content here...
\end{alltt}
The same thing happens in HTML output (though not as noticible). The marked up parsed-literal gets rendered with 'default-highlight' but the one with the replacement gets rendered with 'literal-block'.
pburdine
commented
May 14, 2016
|
I see the same thing. For example:
In other places I used rst replacements like:
In the first example, in the PDF output it shows up like a normal code block (black border, syntax highlighting, etc), but the second example doesn't In the .tex file for the marked up parsed-literal it looks like:
But in the parsed-literal with the substitution, it renders like:
The same thing happens in HTML output (though not as noticible). The marked up parsed-literal gets rendered with 'default-highlight' but the one with the replacement gets rendered with 'literal-block'. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pburdine
May 16, 2016
It looks like this is related to the following code in the latex writer:
def visit_literal_block(self, node):
if self.in_footnote:
raise UnsupportedError('%s:%s: literal blocks in footnotes are '
'not supported by LaTeX' %
(self.curfilestack[-1], node.line))
if node.rawsource != node.astext():
# most probably a parsed-literal block -- don't highlight
self.body.append('\\begin{alltt}\n')
else:
ids = ''
for id in self.pop_hyperlink_ids('code-block'):
ids += self.hypertarget(id, anchor=False)
if node['ids']:
# suppress with anchor=False \phantomsection insertion
ids += self.hypertarget(node['ids'][0], anchor=False)
The same if statement can be seen in the html writer:
def visit_literal_block(self, node):
if node.rawsource != node.astext():
# most probably a parsed-literal block -- don't highlight
return BaseTranslator.visit_literal_block(self, node)
...
I don't know enough about the code to determine what triggers:
if node.rawsource != node.astext()
Maybe someone who knows this better can comment on this.
pburdine
commented
May 16, 2016
•
|
It looks like this is related to the following code in the latex writer:
The same if statement can be seen in the html writer:
I don't know enough about the code to determine what triggers: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tk0miya
May 16, 2016
Member
Indeed, it is strange for me that parsed-liateral block having substituion is not highlighted.
BTW, I prefer to highlight parsed-literal as far as possible.
|
Indeed, it is strange for me that parsed-liateral block having substituion is not highlighted. BTW, I prefer to highlight parsed-literal as far as possible. |
tk0miya
added
the
markup
label
May 16, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreacassioli
May 16, 2016
Guys thank you for your effort.
I remember there was a discussion on the G group (I cannot find it anymore...) about this: If I am not wrong some of the Sphinx team said that it was hard to decide how to pygmentize the parsed text. It seems that now if there is some transformation in place the text is not highlighted. Is this correct?
That sounds very limiting....
andreacassioli
commented
May 16, 2016
|
Guys thank you for your effort. That sounds very limiting.... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pburdine
Jun 10, 2016
In #2173 @lehmannro said:
(DefaultSubstitutions won't help, since these are used as Text nodes as well.)
This explains what I am seeing, not sure if this is the cause of what @andreacassioli sees.
pburdine
commented
Jun 10, 2016
|
In #2173 @lehmannro said:
This explains what I am seeing, not sure if this is the cause of what @andreacassioli sees. |
spencer-rig
referenced this issue
Jan 6, 2017
Closed
Parsed-literals don't wrap very long lines with pdf builder #3308
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
paulanthonyjacobs
Jan 23, 2017
I noticed some other inconsistencies using embedded replacements inside parsed-literal (but haven't delved into why). For e.g.
|token|-|token|
blah/|token|
expand ok, but
|token|.|token|
|token||token|
don't. Anyone know why or offer some work-arounds?
paulanthonyjacobs
commented
Jan 23, 2017
|
I noticed some other inconsistencies using embedded replacements inside parsed-literal (but haven't delved into why). For e.g. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jfbu
Jan 23, 2017
Contributor
@paulanthonyjacobs in my brief testing
|token|\ .\ |token|
|token|\ |token|
works for me. I actually trust the syntax coloring of my Emacs reST mode and 1, 3, 4 in
|token|-|token| (1)
blah/|token| (2)
|token|.|token| (3)
|token||token| (4)
seem faulty for this point of view, although indeed only on the two latest have seemingly rendering problem (tested in html) and the last one actually raises an error
index.rst:15: ERROR: Undefined substitution referenced: "token||token".
hence I tried
|token|\ -|token|
blah/|token|
expand ok, but
|token|.\ |token|
|token|\ |token|
because syntax coloring is fine and indeed it seems ok for make html.
|
@paulanthonyjacobs in my brief testing
works for me. I actually trust the syntax coloring of my Emacs reST mode and 1, 3, 4 in
seem faulty for this point of view, although indeed only on the two latest have seemingly rendering problem (tested in html) and the last one actually raises an error
hence I tried
because syntax coloring is fine and indeed it seems ok for make html. |
andreacassioli commentedDec 11, 2015
Hi,
I have realized that the html output of parsed-literal depends on whether links are included or not. For instance:
will generate a single line with highlighted code
but
will yield a single line but with not highlight. Note that the link is valid and it will work nicely.
My point is: there should be a consistent behaviour. Of course would be nice to have always highlight (or an option to have it).