Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx 1.3.5: Could not parse literal_block as "language" #2264

Closed
stevepiercy opened this issue Jan 24, 2016 · 10 comments
Closed

Sphinx 1.3.5: Could not parse literal_block as "language" #2264

stevepiercy opened this issue Jan 24, 2016 · 10 comments
Assignees

Comments

@stevepiercy
Copy link
Contributor

The following might not be a bug, but it is a changed behavior that enforces stricter syntax, and should be noted.

How to reproduce

For this code sample (and several others):

.. code-block:: ini
   :linenos:

   [app:main]
   ...
   pyramid.includes =
       pyramid_debugtoolbar

Sphinx 1.3.4 yielded no errors. Upgrading to 1.3.5 and attempting to build HTML causes the following error:

/home/travis/build/Pylons/pyramid/docs/narr/project.rst:434: WARNING: Could not parse literal_block as "ini". highlighting skipped.

How to Fix/Workaround

Use a comment for elided output instead of a literal .... It appears that one can no longer use incorrect syntax for a given language for highlighting.

.. code-block:: ini
   :linenos:

   [app:main]
   # ... elided configuration
   pyramid.includes =
       pyramid_debugtoolbar

The screenshot compares two examples, where the first is highlighted but the second is not.

google chrome005

I noticed that this shows up for javascript or posh syntaxes, too.

Possibly related to #2262.

@birkenfeld
Copy link
Member

The second block would have been unhighlighted in previous Sphinx versions too. Only the warning is new to make you aware of it.

@stevepiercy
Copy link
Contributor Author

@birkenfeld is this a change in Pygments or Sphinx? Either way, it's a good change that helped me catch a couple of other mistakes.

@birkenfeld
Copy link
Member

This was added to Sphinx in #1565.

@stevepiercy stevepiercy changed the title Sphinx 1.3.5: Could parse literal_block as "language" Sphinx 1.3.5: Could not parse literal_block as "language" Jan 24, 2016
@stevepiercy
Copy link
Contributor Author

Would it be helpful to add to the change log something like this?

If the syntax is incorrect for the :language: option in a .. code-block:: directive, Sphinx will now emit a warning as follows.

WARNING: Could not parse literal_block as "<language>". highlighting skipped.

Reasoning: When searching the change log, I could not find anything relevant to "literal_block". This would link the error message to a specific change log entry and provide a clue for what changed in 1.3.5 and how to fix it.

Alternatively, the warning message could refer to the specific directive that literal_block refers to, e.g.,

WARNING: Could not parse code-block as "<language>". highlighting skipped.

I can submit a PR, but the change log is very terse, and I wouldn't want to break that pattern.

If not, then this issue can be closed, and at the least this discussion can be indexed by search engines.

@tk0miya
Copy link
Member

tk0miya commented Jan 25, 2016

OK, I'll update it later.

@tk0miya tk0miya self-assigned this Jan 25, 2016
tk0miya added a commit that referenced this issue Jan 26, 2016
@tk0miya
Copy link
Member

tk0miya commented Jan 26, 2016

@stevepiercy This change also effects to other directives (cf. literalinclude, parsed-literal and so on).

So I rewrite changelog as follows:

Thanks,

@tk0miya tk0miya closed this as completed Jan 26, 2016
@stevepiercy
Copy link
Contributor Author

Thank you!

greg0ire pushed a commit to greg0ire/SonataAdminBundle that referenced this issue Jan 28, 2016
greg0ire pushed a commit to greg0ire/SonataAdminBundle that referenced this issue Jan 28, 2016
greg0ire pushed a commit to greg0ire/SonataAdminBundle that referenced this issue Jan 28, 2016
greg0ire pushed a commit to greg0ire/SonataAdminBundle that referenced this issue Jan 29, 2016
see sphinx-doc/sphinx#2264
Should fix the build.

Conflicts:
	Resources/doc/cookbook/recipe_sortable_listing.rst
	Resources/doc/reference/architecture.rst
	Resources/doc/reference/getting_started.rst
sakarikl pushed a commit to sakarikl/SonataAdminBundle that referenced this issue Feb 8, 2016
@karelyatin
Copy link

If i use sphinx 1.6.2 or 1.6.3 with pygments<=2.1.3 the following error is reported:
Could not lex literal_block as "ini". Highlighting skipped.

But with pygments 2.2 The above error is not reported.

@jean
Copy link
Contributor

jean commented Oct 8, 2017

Is it possible to log in more detail why lexing failed?

@tk0miya
Copy link
Member

tk0miya commented Oct 8, 2017

@jean could you file a new issue please? I'll take a look later.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants