Giter VIP home page Giter VIP logo

Comments (7)

bsipocz avatar bsipocz commented on July 26, 2024

I think has something to do with the asdf directive, however it's a bit complicated so I didn't find a quick solution.

In the meantime I've fixed the sphinx version to <1.3.5 in #194 so they won't show up in every PR.

from asdf.

nden avatar nden commented on July 26, 2024

Yes, it's in the definition of the AsdfDirective class but I haven't had time to look into it.
It's a warning that Pygments could not do correct language highlighting so it's not critical although it would be nice to fix it.

from asdf.

embray avatar embray commented on July 26, 2024

The problem appears to be here. The problem is that the AsdfDirective is creating a single literal_block node containing the ASDF header followed by the YAML tree. The whole block is marked as having the language "yaml", but the ASDF header is not valid YAML (well, arguably it's a comment in YAML, but my guess--and I haven't confirmed this--is that the syntax highlighter doesn't support comments coming before the %YAML directive).

Technically, according to the low-level layout of the ASDF format the header is a separate section of the file from the YAML tree anyways. So I think a fix to this would be to change the AsdfDirective slightly to output the header in a separate literal node from the tree (just as it outputs the block headers as a separate node currently).

from asdf.

embray avatar embray commented on July 26, 2024

Nevermind--that doesn't appear to be exactly the issue after all. I tested it and the yaml highligher from pygments had no problem with this, at least not directly (still might make sense to put the header in a separate node though).

from asdf.

embray avatar embray commented on July 26, 2024

Okay, I think I see where the problem probably is. I think it's a bug in the pygments lexer. It's barfing on lines like this one:

asdf_library: !core/software-1.0.0 {author: Space Telescope Science Institute, homepage: 'http://github.com/spacetelescope/asdf',
  name: asdf, version: 1.1.0.dev722}

If I remove the !core/software-1.0.0 tag it works. So it seems that it can't handle an inline map element split across multiple lines if it is preceded by a tag.

Update: Further narrowed it down. It's fine with having a tag there, but it doesn't like the / in the tag name.

from asdf.

embray avatar embray commented on July 26, 2024

Here we go:
https://bitbucket.org/birkenfeld/pygments-main/pull-requests/584/fix-incorrect-lexing-of-yaml-tags/diff

In principle we can work around this now by monkey-patching. The AsdfDirective (or the module containing it) can import the YamlLexer from pygments and update YamlLexer.tokens['descriptors'] to use my updated regexp.

from asdf.

embray avatar embray commented on July 26, 2024

My fix to the pygments lexer has been merged.

from asdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.