Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugly MarkupContent formatting #606

Open
rcasta74 opened this issue Dec 7, 2024 · 0 comments
Open

Hugly MarkupContent formatting #606

rcasta74 opened this issue Dec 7, 2024 · 0 comments

Comments

@rcasta74
Copy link

rcasta74 commented Dec 7, 2024

Here a comparison between pyright and pylsp using coc.nvim plugin:

  1. pyright
[Trace - 3:54:33 PM] Received response 'textDocument/hover - (11)' in 4ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "```python\n(function) def load(\n    fp: SupportsRead[str | bytes],\n    *,\n    cls: type[JSONDecoder] | None = None,\n    object_hook: ((dict[Any, Any]) -> Any) | None = None,\n    parse_float: ((str) -> Any) | None = None,\n    parse_int: ((str) -> Any) | None = None,\n    parse_constant: ((str) -> Any) | None = None,\n    object_pairs_hook: ((list[tuple[Any, Any]]) -> Any) | None = None,\n    **kwds: Any\n) -> Any\n```\n---\nDeserialize `fp` (a `.read()`-supporting file-like object containing\na JSON document) to a Python object.\n\n`object_hook` is an optional function that will be called with the\nresult of any object literal decode (a `dict`). The return value of\n`object_hook` will be used instead of the `dict`. This feature\ncan be used to implement custom decoders (e.g. JSON-RPC class hinting).\n\n`object_pairs_hook` is an optional function that will be called with the\nresult of any object literal decoded with an ordered list of pairs.  The\nreturn value of `object_pairs_hook` will be used instead of the `dict`.\nThis feature can be used to implement custom decoders.  If `object_hook`\nis also defined, the `object_pairs_hook` takes priority.\n\nTo use a custom `JSONDecoder` subclass, specify it with the `cls`\nkwarg; otherwise `JSONDecoder` is used."
    },

2024-12-07_16-54

  1. pylsp
[Trace - 3:54:33 PM] Received response 'textDocument/hover - (10)' in 6ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "```python\nload(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any\n```\n\n\nDeserialize ``fp`` (a ``.read()``-supporting file-like object containing\na JSON document) to a Python object.\n\n``object\\_hook`` is an optional function that will be called with the\nresult of any object literal decode (a ``dict``). The return value of\n``object\\_hook`` will be used instead of the ``dict``. This feature\ncan be used to implement custom decoders (e.g. JSON-RPC class hinting).\n\n``object\\_pairs\\_hook`` is an optional function that will be called with the\nresult of any object literal decoded with an ordered list of pairs.  The\nreturn value of ``object\\_pairs\\_hook`` will be used instead of the ``dict``.\nThis feature can be used to implement custom decoders.  If ``object\\_hook``\nis also defined, the ``object\\_pairs\\_hook`` takes priority.\n\nTo use a custom ``JSONDecoder`` subclass, specify it with the ``cls``\nkwarg; otherwise ``JSONDecoder`` is used."
    }

2024-12-07_14-52

So with pylsp

  • code block is formatted as one-line
  • code spans contain backslash escapes that are treated literally as per GitHub Flavored Markdown Spec (they are not present if plaintext format is requested)

Could this be improved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant