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

Hyperlinks consume space though the link isn't printed #45

Open
anicolao opened this issue Jan 30, 2022 · 1 comment
Open

Hyperlinks consume space though the link isn't printed #45

anicolao opened this issue Jan 30, 2022 · 1 comment

Comments

@anicolao
Copy link

anicolao commented Jan 30, 2022

I was modifying glamour to output links without the anchor text, but this uses up "space" in wordwrap.go even though it ideally would know that the anchor text does not get displayed by the terminal.

Here's a printf example that you can use to see what the link output looks like:

$ printf '\e]8;;file:./SECURITY.md\e\\This is a link\e]8;;\e\\\n'

So the bytes from file:./SECURITY.md should not be counted towards the block's wordwrapping. Here's an example of how it fails to look correct:

$ ./glow ~/projects/kitty/CONTRIBUTING.md 

  ### Reporting bugs                                                                                
                                                                                                    
  Please first search existing bug reports (especially closed ones) for a report that matches your  
  issue.                                                                                            
                                                                                                  
  When reporting a bug, provide full details of your environment, that means, at a minimum, kitty   
  version, OS and OS version, kitty config (ideally a minimal config to reproduce the issue with).  
                                                                                                    
  ### Contributing code                                                                             
                                                                                                    
  Install the dependencies using your favorite  
  package manager. Build and run kitty from source.                                                                                
                                                                                                  
  Make a fork, submit your Pull Request. If it's a large/controversial change, open an issue        
  beforehand to discuss it, so that you don't waste your time making a pull request that gets       
  rejected.                                                                                         
                                                                                                  
  If the code you are submitting is reasonably easily testable, please contribute tests as well (see
  the  kitty_tests/  sub-directory for existing tests, which can be run with  ./test.py ).          
                                                                                                  
  That's it.                                                                                        

Note how the middle paragraph that contains a link for "the dependencies" and a link for "from source" cause the paragraph to be badly wrapped, the same as if the URL was inline:


$ glow ~/projects/kitty/CONTRIBUTING.md 

  ### Reporting bugs                                                                                
                                                                                                    
  Please first search existing bug reports (especially closed ones) for a report that matches your  
  issue.                                                                                            
                                                                                                  
  When reporting a bug, provide full details of your environment, that means, at a minimum, kitty   
  version, OS and OS version, kitty config (ideally a minimal config to reproduce the issue with).  
                                                                                                    
  ### Contributing code                                                                             
                                                                                                    
  Install the dependencies https://sw.kovidgoyal.net/kitty/build/#dependencies using your favorite  
  package manager. Build and run kitty from source https://sw.kovidgoyal.net/kitty/build/#install-and-
  run-from-source.                                                                                  
                                                                                                  
  Make a fork, submit your Pull Request. If it's a large/controversial change, open an issue        
  beforehand to discuss it, so that you don't waste your time making a pull request that gets       
  rejected.                                                                                         
                                                                                                  
  If the code you are submitting is reasonably easily testable, please contribute tests as well (see
  the  kitty_tests/  sub-directory for existing tests, which can be run with  ./test.py ).          
                                                                                                  
  That's it.                                                                                        
@anicolao
Copy link
Author

anicolao commented Feb 1, 2022

It's even worse than this; the margin and indent code don't understand that the link anchor following the OSC escape doesn't make it to the screen, so they will wrap it (breaking the links) and indent it, too. Essentially the code would need to understand the actual rules for what's part of the escape code, which it currently does not and which seems to be implemented a few places in the codebase.

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