Code Monkey home page Code Monkey logo

Comments (4)

MichaelDeBoey avatar MichaelDeBoey commented on August 25, 2024

Hi @lekterable!

Thanks for reporting this.

Can you provide me with a reproduction link (CodeSandbox) or repo so I can dig into this further, please? 🤔

from gatsby-remark-embedder.

MichaelDeBoey avatar MichaelDeBoey commented on August 25, 2024

Hi @lekterable!

If I understand your request correctly, I think this isn't something that can be fixed.
If you look at the AST that's created, you'll see that each link will give you the exact same Node.
This means there's no way to know the difference between all 3 of them.

Since this plugin is looking if there's a link on a single line and it's the only thing on that line before transforming it, I suggest you don't put it on a single line or you put some extra braces (()) around it.

from gatsby-remark-embedder.

lekterable avatar lekterable commented on August 25, 2024

Hey @MichaelDeBoey , sorry I wasn't much help in creating a sandbox for those issues and huge thanks for fixing the first one! I've looked at the AST you've linked and I think I might see a way of tackling this.
Every node has a property position -> start -> column which from what I understand indicates where exactly in the text this given link was found.

"children": [
            {
              "type": "text",
              "value": "https://youtube.com/watch?v=dQw4w9WgXcQ",
              "position": {
                "start": {
                  "line": 1,
                  "column": 1,
                  "offset": 0
                },
                "end": {
                  "line": 1,
                  "column": 40,
                  "offset": 39
                },
                "indent": []
              }
            }
          ],

If that's true we could make sure that the plugin only cares about those links that have this property equal to 1 as it would rule out both this:

<https://www.youtube.com/watch?v=dQw4w9WgXcQ>

and

[https://www.youtube.com/watch?v=dQw4w9WgXcQ](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

because for them it will always be 2 :

"children": [
            {
              "type": "text",
              "value": "https://youtube.com/watch?v=dQw4w9WgXcQ",
              "position": {
                "start": {
                  "line": 3,
                  "column": 2,
                  "offset": 42
                },
                "end": {
                  "line": 3,
                  "column": 41,
                  "offset": 81
                },
                "indent": []
              }
            }
          ],

Let me know if that makes sense and if that's the direction you would like to go, if so I'd love to work on a PR for it :)

from gatsby-remark-embedder.

MichaelDeBoey avatar MichaelDeBoey commented on August 25, 2024

@lekterable That would indeed be a possible solution for what you're suggesting.

Since using pure markdown those 3 lines are seen as exactly the same (people expect them to give the same output), I'm not going to do anything about this.

I hope you understand my point of view and why I'm not going to include your proposal into the plugin.

If you have some future improvements, I'm happy to look into them tho! 🙂

from gatsby-remark-embedder.

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.