Comments (12)
Hmm, I'm not sure I ever tested that. It looks like those are pygments styles that are supposed to be written by sphinx, but I must have disabled them at some point. Looking quickly at the sphinx source, I'm not sure how they actually get written into the document. Are you up for looking into it?
from sphinxtr.
I have started looking into it. It is likely something in 'sphinx.sty' that has been commented out.
I should put out the disclaimer that I am not a proper software dev. But would definitely like to make this work.
MR
from sphinxtr.
For reference, here's the original version of the file:
https://bitbucket.org/birkenfeld/sphinx/src/ef3092d458cc00c4b74dd342ea05ba1059a5da70/sphinx/texinputs/sphinx.sty?at=default
I wasn't sure where those pygments styles are coming from in there
from sphinxtr.
I have found a fix for the issue. But it introduces another (but lesser) issue -- which is aesthetic and far less crucial.
Basically, the method depart_literal_block
in the script latex_mod.py
had to be restored to its original form. This fixed the syntax highlighting, but took away the background shading and borders from the code and literal blocks.
def depart_literal_block(self, node):
code = self.verbatim.rstrip('\n')
lang = self.hlsettingstack[-1][0]
linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
highlight_args = node.get('highlight_args', {})
if 'language' in node:
# code-block directives
lang = node['language']
highlight_args['force'] = True
if 'linenos' in node:
linenos = node['linenos']
def warner(msg):
self.builder.warn(msg, (self.curfilestack[-1], node.line))
hlcode = self.highlighter.highlight_block(code, lang, warn=warner,
linenos=linenos, **highlight_args)
# hlcode = hlcode.replace('\$', '$')
# hlcode = hlcode.replace('\%', '%')
# workaround for Unicode issue
hlcode = hlcode.replace(u'€', u'@texteuro[]')
# must use original Verbatim environment and "tabular" environment
if self.table:
hlcode = hlcode.replace('\\begin{Verbatim}',
'\\begin{OriginalVerbatim}')
self.table.has_problematic = True
self.table.has_verbatim = True
# get consistent trailer
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
hlcode = hlcode.rstrip() + '\n'
# hlcode = '\n' + hlcode + '\\end{%sVerbatim}\n' % (self.table and 'Original' or '')
# hlcode = hlcode.replace('Verbatim', 'lstlisting')
# begin_bracket = hlcode.find('[')
# end_bracket = hlcode.find(']')
# hlcode = hlcode[:begin_bracket] + '[]' + hlcode[end_bracket+1:]
# self.body.append(hlcode)
# self.verbatim = None
self.body.append('\n' + hlcode + '\\end{%sVerbatim}\n' %
(self.table and 'Original' or ''))
self.verbatim = None
from sphinxtr.
could you submit it as a pull request and add a code block to the sample?
from sphinxtr.
I can do that. By 'sample' do mean the sample thesis?
from sphinxtr.
Yep, sorry I just meant the sample thesis. I was thinking ch-typography/text.rst
would be a good place for it, next to the simple code block in there.
from sphinxtr.
I tried changing depart_literal_block()
to the one proposed by @marufr and I tried to leave out the method completely (which then should simply default to Sphinx' depart_literal_block()
). In both cases, the output loses the grey block around it, but the code is still not highlighted correctly.
from sphinxtr.
I don't like the idea of using listing
instead of Verbatim
for codeblocks. listing
is a package that does code highlighting for you, and Pygments is a tool that does code highlighting for you. Only using one is okay I think. Using both might be part of the issue why it's not working. I also think there is not much of a decision to make between both, because Pygments also solves the highlighting for HTML. So we better stick with it. If we want to change colors, borders and so on, we can actually do that in the sphinx.sty just fine.
Until now I still don't have a solution to the \PYG
extension, though.
from sphinxtr.
I think I uncommented all interesting parts in sphinx.py
, still no change.
from sphinxtr.
I am currently working on proving or disproving the assumption, that the wrong environment is used. Reason for this is, that the Pygments documentation says, that it needs the fancyvrb package and generates it output in a Verbatim
environment. Because the shown example is a parametrized Verbatim
environment I guess it uses not the default, but an Environment changed by the fancyvrb
package.
edit: Commenting out the fancyvrb
library in my normal Sphinx devenv results in the same bad output as in my sphinxtr devenv.
edit: got it working. create pull request now.
from sphinxtr.
I tried @erikb85's changed (hand merged, might have made some typos) and they seem to work for me. To get grey boxes I used:
\definecolor{VerbatimColor}{rgb}{0.95,0.95,0.95}
\definecolor{VerbatimBorderColor}{rgb}{0.75,0.75,0.75}
I discovered the problem when I found underline characters being escaped in my code blocks; python code was also broken.
@erikb85, can you submit a pull request?
from sphinxtr.
Related Issues (20)
- big tables - whats the deal ? HOT 9
- Responsive Web Design (Mobile/Tablet Support)
- WAI-ARIA Roles
- Â in 'Text' version
- ePub / Mobi (ebook formats) HOT 2
- How to add a Glossary? HOT 3
- numfig bug: :page: references wrong label from one chapter to another
- Error using latexpdf HOT 3
- numsec: Keep node structure HOT 1
- Issue when using numfig extension: can't compile HTML HOT 2
- Multi-paragraph caption of figtable (extend/document)
- Sphinx >= 1.3.0 breaks latex_mods (previous_spanning_row removed from the LaTeX builder) HOT 5
- Can not import numfig and natbib HOT 1
- Name collision with backports package HOT 1
- readme.md incorrectly links to PDF
- Installation not very clear HOT 5
- Whitespace violations in code HOT 1
- What is the license of the code?
- latex_mods.py extension breaks with Sphinx 1.5 HOT 2
- newlines doens't work in figtable multiline cells
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sphinxtr.