Giter Site home page Giter Site logo

Comments (2)

martinpakosch avatar martinpakosch commented on May 29, 2024 1

Hi,

thanks for the explanation.

The .multi part is not checked for, as single-quoted docstrings are still technically valid docstrings in Python.

Oh... that's something I did not know until now, although I am using Python quite long. Well, then it explains what I saw. During some experiments with custom highlighting, also with your extension, searching for a solution that matches my needs, I simply injected a single-quoted string under my triple-quote docstring to test "scope escaping", not knowing that VSCode's grammar correctly maps it to the "docstrings" as highlighting does not differ (in my theme) from strings in assignments or other expressions.

So basically my mistake and your extension seems to work perfectly at this point. :D

Do you plan to add more syntaxes? Like inline monospaced literals with two back-ticks? Or will you keep just the support role-syntax?

And is it possible to customize the colors? Currently the detected roles are highlighted (in my theme) with the same color as my Python keywords like def or return. Would be nice to dim that by setting custom colors in your extension.

Edit:

Forget about the last two. :D Now I see your supported syntaxes and that you also inject the .sphinx scope. That should make customization for me simple. Gonna try this.

So you can close this now. :D Sorry for bothering you. ;)

from python-sphinx-highlighter.

leonhard-s avatar leonhard-s commented on May 29, 2024

Hi, this extension injects its highlighting into string.quoted.docstring scopes for the source.python grammar, as you suggested. The .multi part is not checked for, as single-quoted docstrings are still technically valid docstrings in Python.

I originally considered using existing reST highlighting for this injection, but decided against it as it tends to colour docstrings differently from other Python strings for many syntax themes. It also broke compatibility with mixed style projects that use Google or NumPy styles for arguments and parameters but still have Sphinx references for use with Napoleon in built docs.

IIRC it is possible for the selectors of the injected grammar to spill beyond its enclosing scope's if a RegEx attempts to lookahead past the end of its parent scope, but this extension does not use anything sufficiently greedy.

Could you share a minimal reproducible example for the highlighting escaping its docstring? Cheers.

from python-sphinx-highlighter.

Related Issues (12)

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.