Giter Club home page Giter Club logo

Comments (11)

joostkremers avatar joostkremers commented on July 23, 2024 1

So it's the LSP server that's sending mangled content? In that case I might consider raising the issue there.

Thanks for looking into this!

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

Do you just recently start to see these? I can easily fix this but I want to make sure recent changes aren't breaking something that I'm not aware of.

from eldoc-box.

joostkremers avatar joostkremers commented on July 23, 2024

I only started using eglot yesterday (been using lsp-mode until now), so I can't tell if they are recent or older.

from eldoc-box.

joostkremers avatar joostkremers commented on July 23, 2024

The   codes are gone, thanks!

Since you mention people should file issues if they find things that can be prettified, I hope you don't mind if I report a few more issues. Completely up to you to decide if you want to do something about them, of course. They are not as conspicuous as the   thing, so I'm a happy camper either way.

  • Some characters appear with backslash escapes. These seem to be characters that have a special meaning in Markdown: the ones I'm seeing are underscore and asterisk.
  • double underscore at the end of some lines. (This might be a fontification effect of markdown-mode, because that's how it signals a double space at the end of a line, although in the actual doc string, there are no double spaces.)
  • Emoji shortcodes aren't rendered. In the doc string, they are written ``+1`` and ``:sunglasses:``, and they should probably be rendered that way. (BTW, emoji are otherwise displayed just fine, so I assume it's not a font issue.)

Screenshot from 2023-03-10 01-43-09

FWIW, here is the doc string as found in the source code:

        """Display string formatted as Markdown.

        Parameters
        ----------
        body : str
            The string to display as Github-flavored Markdown. Syntax
            information can be found at: https://github.github.com/gfm.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet.

        unsafe_allow_html : bool
            By default, any HTML tags found in the body will be escaped and
            therefore treated as pure text. This behavior may be turned off by
            setting this argument to True.

            That said, we *strongly advise against it*. It is hard to write
            secure HTML, so by using this argument you may be compromising your
            users' security. For more information, see:

            https://github.com/streamlit/streamlit/issues/152

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> st.markdown('Streamlit is **_really_ cool**.')
        >>> st.markdown(”This text is :red[colored red], and this is **:blue[colored]** and bold.”)
        >>> st.markdown(":green[$\sqrt{x^2+y^2}=1$] is a Pythagorean identity. :pencil:")

        """

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

I only started using eglot yesterday (been using lsp-mode until now), so I can't tell if they are recent or older.

Ah, then it makes sense, very good.

Since you mention people should file issues if they find things that can be prettified, I hope you don't mind if I report a few more issues. Completely up to you to decide if you want to do something about them, of course. They are not as conspicuous as the   thing, so I'm a happy camper either way.

Yes, reports are very welcome. And thank you for your detailed reports!

The report clearly went through some processing before displayed by eldoc-box, could you run M-x eldoc-doc-buffer and copy the content of this buffer to here? Also the content of Eglot's event buffer (opened by eglot-events-buffer), if you can. The events buffer will be very large so maybe save it into a file.

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

BTW, as a user, do you prefer monospace or sans serif for eldoc-box's documentation?

from eldoc-box.

joostkremers avatar joostkremers commented on July 23, 2024

eldoc-doc-buffer:

```python
(variable) markdown: (body: SupportsStr, unsafe_allow_html: bool = False) -> DeltaGenerator
```
---
Display string formatted as Markdown.

Parameters
----------
body : str  
    The string to display as Github-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.

    This also supports:

  * Emoji shortcodes, such as ``  and ``.
For a list of all supported codes,
see https://share.streamlit.io/streamlit/emoji-shortcodes.

  * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
must be on their own lines). Supported LaTeX functions are listed
at https://katex.org/docs/supported.html.

  * Colored text, using the syntax `:color[text to be colored]`,
where `color` needs to be replaced with any of the following
supported colors: blue, green, orange, red, violet.

unsafe\_allow\_html : bool  
    By default, any HTML tags found in the body will be escaped and
therefore treated as pure text. This behavior may be turned off by
setting this argument to True.

    That said, we \*strongly advise against it\*. It is hard to write
secure HTML, so by using this argument you may be compromising your
users' security. For more information, see:

    https://github.com/streamlit/streamlit/issues/152

Examples
--------
```
>>> import streamlit as st
>>>
>>> st.markdown('Streamlit is **_really_ cool**.')
>>> st.markdown(”This text is :red[colored red], and this is **:blue[colored]** and bold.”)
>>> st.markdown(":green[$\sqrt{x^2+y^2}=1$] is a Pythagorean identity. :pencil:")
```

I put eglot-event-buffer in a gist: https://gist.github.com/joostkremers/a809060209255a822ce758b6c7ecd933

eldoc-doc-buffer is also in the gist, just in case.

What you cannot easily see from this is that the double underscore after str and bool are indeed double spaces fontified by markdown-mode. (I checked with C-u C-x =.) If you select the text above, you'll notice that there are two spaces. They do not exist in the original doc string.

from eldoc-box.

joostkremers avatar joostkremers commented on July 23, 2024

BTW, as a user, do you prefer monospace or sans serif for eldoc-box's documentation?

I definitely prefer monospace, for the superbly objective reason that it's an editor, darn it, and editors should use monospace! 😄

Actually, I do use sans serif in Emacs, primarily in text (markdown) buffers, but documentation is code-related, and for me, that means monospace. But that's just my €0.02, of course.

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

Ok, I can fix the underlined spaces but not the backslashes and disappearing emojis.

The backslash is too unspecific. Eldoc-box can receive plain text or markdown, so it can't be sure that a backslash is a markdown escape rather than a plain backslash. The backslash is best handled in markdown-mode, which eglot uses to render the markdown doc.

The emoji are stripped out for some reason even before python LSP sends the doc to eglot (judging by the eglot events log), so there aren't anything we can do.

from eldoc-box.

casouri avatar casouri commented on July 23, 2024

I think so, look at line 375 in eglot-events-buffer.txt:

...* Emoji shortcodes, such as ``  and ``.\n...

from eldoc-box.

joostkremers avatar joostkremers commented on July 23, 2024

Yes, I noticed those, too. Just wasn't sure what it meant, i.e., if that's literally what the LSP server sends or if it had already been modified by eglot.

from eldoc-box.

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.