GithubHelp home page GithubHelp logo

Comments (18)

cjw296 avatar cjw296 commented on August 19, 2024 1

I think I've got a reasonable amount of this done already on master...skip_improvements
Can you have a look and let me know what you think?

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024 1

@sscherfke - last call on this, I'm planning a 6.0.0 release sometime in the next day or few...

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024 1

No, but you're right that it's missing and I've implemented in 89d3eee

Could you have a look at master now and see if that meets all your needs?

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024 1

I am happy now (and healthy again). :-)

Thanks a lot for your efforts! <3

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

I skimmed through the changes.

They seem to fix my requirements 1–3 (parse :key: value options from myst/rest directive and add them to the lexemes).

The evaluator stack seems to solve my requirements for 5: I can instantiate a CodeBlockParser for console or toml (or the PythonCodeBlockParser) and push an evaluator that looks for :caption: file.ext and raises a NotEvaluated if it's not there, which would cause the default evaluators (e.g., doctest evaluator for PythonCodeBlock) to kick in. Is that correct?

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

So, coming back to this testfixtures supports what you're after but with different spelling. It's a great library, but then I'm biased since I'm its author ;-)

I think master supports what you're after, but I'm not sure I'd use the evaluator stack, just a specialised CodeBlockParser.

Can you have a look at current master and let me know if you still feel anything is missing?

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

I’ll try to test the new changes and give you feedback, but had no time for this yet.

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

Wasn't there directive option parsing for the MyST lexers, too, in the feature branch skip_improvements? In the current master, it's only there for ReST.

It would be cool if that feature was also available for Myst. This is the regex I am currently using:

MYST_START_PATTERN = (
    r"^(?P<prefix>[ \t]*)"
    r"```\{(?P<directive>code-block)}\s*"
    r"(?P<arguments>[\w-]+\b)$\n"
    r"(?P<options>(?:\s*\:[\w-]+\:.*\n)*)?"
)

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

@sscherfke - I'll take the thumbs up as "all good now", please let me know if you spot anything else and we can re-open this.

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

It's a thumbs up for "I’ll test it and report back" ;-)

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

Okay, I found two issues:

  1. I think the options need to be forwared to the Region so that they are accessible in a parser. It needs to be added here: https://github.com/simplistix/sybil/blob/master/sybil/parsers/abstract/codeblock.py#L56
    Like this (but as an actual class attribute ;-)):
                    r = Region(lexed.start, lexed.end, lexed.lexemes['source'], self.evaluate)
                    r.options = lexed.lexemes.get("options", {})
                    yield r
  2. The options in myst blocks must be enclosed with ---, but the MyST docs seem recommend options without ---: https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html – I posted a regex that is able to parse this above.

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

I can provide a PR as base, if you like :)

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024
  1. Both styles are already supported:
    ```{image} picture.png
    ```
    ```{image} picture.jpeg
    :height: 100px
    :width:200 px
    :scale: 50 %
    :alt: alternate text
    :align: right
    ```
    ```{figure} picture.png
    ---
    scale: 50 %
    alt: map to buried treasure
    ---

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024
  1. f6d8772 shows how I'd currently do the kind of thing you're after, but I'm now wondering in LexedRegion actually needs to exist...

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024
  1. I need to access the options in self.evaluate(), so overriding self.__call__() as in that test example does not work for me, I guess: https://gitlab.com/sscherfke/typed-settings/-/blob/main/conftest.py?ref_type=heads#L213
  2. You're right. A mistake on my side :)

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

I'm not sure doing what you're doing in self.evaluate() is right here; you're essentially picking between two evaluators based on an option in the ReST or MyST directive, so you should code it as such rather than trying to do both in a since evaluate method.

However, as of 59045ff I think you can do either. Let me know what you think.

from sybil.

sscherfke avatar sscherfke commented on August 19, 2024

Hi Chris, I got sick last week. Will try your changes asap and provide feedback.

from sybil.

cjw296 avatar cjw296 commented on August 19, 2024

Very sorry to hear that, hope you're feeling better soon! 6.0.0 is out now with all the changes in it, so please give it a spin and it me know how it goes :-)

from sybil.

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.