Giter VIP home page Giter VIP logo

Comments (3)

zkat avatar zkat commented on July 3, 2024

Yeah, overlapping spans are not really... well supported (read: supported). Mostly because I couldn't figure out how to support them well? What do you think this should render as?

My recommendation otherwise is to make sure your single-line spans aren't overlapping, which isn't great. We do have choices, I just don't know which one to pick. I'd love a PR if that's something you're interested in doing, though :)

from miette.

olson-sean-k avatar olson-sean-k commented on July 3, 2024

What do you think this should render as?

I think the main problem is that the here label doesn't point at the beginning, end, or middle of the relevant source text. Just pointing at the beginning (or really anywhere within the span) could be better.

   ,----
 1 | {foo,**,bar,baz}
   : ^^^^^|^^^^^^^^^^
   :      `--|-- here
   :         `-- in this alternative
   `----

Even better (and possibly easier to implement) may be to provide separate underlines for spans over more than one character. In this case, that could look something like the following.

   ,----
 1 | {foo,**,bar,baz}
   : ^^^^^^^^^^^^^^^^
   :      ^^ |
   :      |  |
   :      |  `-- in this alternative
   :      `----- here
   `----

While it's a bit verbose, I think I would personally prefer this rendering since it makes the spans very clear. Any spans that refer to a single character could instead "punch through" a bit like the first example.

   ,----
 1 | {foo,**,bar,baz}
   : ^^^^^^^^^^^^|^^^
   :      ^^ |   `-- you goofed right here too
   :      |  |
   :      |  `-- in this alternative
   :      `----- here
   `----

I think this works so long as the difference between ^ and | beneath the source text is consistent. For multiline source text, this may remain clear so long as the number of necessary underlines wrap with the lines.

   ,----
 1 | Everything is okay. Oh No,
   :                     ^^^|^^
   :                        `-- uppercase?
 2 | I was very wrong!
   : ^^^^^^^^^^^^^^^^^
   :    |  ^^^^
   :    |   |
   :    |   `-- so very
   :     `----- it happens
   `----

   ,----
 1 | Memory safety isn't
   : ^^^^^^^^^^^^^^^^^^^
   :               ^^^^^
 2 | necessary at all.
   : ^^^^^^^^^^^^^^^^^
   : ^^^|^^^^^^^^^^^^
   :    |   |
   :    |   `-- especially this part
   :     `----- I don't like this statement
   `----

Colored output would make the various spans a lot clearer when things get more complex. 😄 Any thoughts on these examples?

from miette.

zkat avatar zkat commented on July 3, 2024

I think your last example might be my favorite honestly. I think it's pretty doable too.

Do you wanna give it a shot? I'm happy to give pointers!

from miette.

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.