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

Formatting \href when using urls in both arguments #3290

Closed
sujaldev opened this issue Oct 25, 2023 · 2 comments
Closed

Formatting \href when using urls in both arguments #3290

sujaldev opened this issue Oct 25, 2023 · 2 comments
Labels
enhancement New feature or (non bug related) change to the program. wontfix Issue will be discarded by the development team.

Comments

@sujaldev
Copy link

Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version

PyCharm 2023.21 (Build #PY-232.9559.58, built on August 22, 2023)

Operating System

Fedora Linux 38

TeXiFy IDEA version

0.9.1

What I did (steps to reproduce)

Go to Settings > Editor > Code Style > LaTeX:

  • set visual guides to 120.
  • enable the "Ensure right margin is not exceeded" option.

Then try to format the below example.

Minimal example to reproduce the problem

\documentclass{article}
\begin{document}

\href{https://example.com/really/loooooong/loooooong/url/}{\url{https://example.com/url/that/exceeds/right/margin}}
    
\end{document}

Expected behavior

I don't know what's the correct way to format it, possibly to just leave it alone on an entire line of it's own (unintended rhyme).

Actual behavior

A newline is added before the last curly bracket on every reformat action.

@sujaldev sujaldev added bug Deficiencies in TeXiFy behaviour. untriaged Issue type still needs to be triaged or verified. labels Oct 25, 2023
@PHPirates
Copy link
Collaborator

Are you sure you are using href correctly? As far as I know, it should be used as \href{https://my-url}{text describing url}, and then it works as I would expect:
\href{https://example.com/really/loooooong/loooooong/url/}{\textit{text text text text text text text text text text text text}}
wraps to

    \href{https://example.com/really/loooooong/loooooong/url/}{\textit{text text text text text text text text text 
    text text text}}

Maybe there is room for improvement though, I think the Kotlin formatter would do something more like this:

    \href{https://example.com/really/loooooong/loooooong/url/}{
        \textit{text text text text text text text text text text text text}
    }

which looks slightly nicer but I'm not 100% sure if this is the same to latex, because of the extra spaces. What do you think?

@PHPirates PHPirates added more-info-needed More information is needed from the person filing the issue. enhancement New feature or (non bug related) change to the program. and removed untriaged Issue type still needs to be triaged or verified. bug Deficiencies in TeXiFy behaviour. labels Oct 27, 2023
@PHPirates PHPirates changed the title A newline is added on each reformat when using the \href command and exceeding wrap limit. Formatting \href when using urls in both arguments Oct 27, 2023
@sujaldev
Copy link
Author

My bad, I seem to have forgotten that \url also creates a clickable link! The formatting in the last example does look better to me.

@PHPirates PHPirates added wontfix Issue will be discarded by the development team. and removed more-info-needed More information is needed from the person filing the issue. labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or (non bug related) change to the program. wontfix Issue will be discarded by the development team.
Projects
None yet
Development

No branches or pull requests

2 participants