Skip to content

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

@anicolao

Description

@anicolao

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.                                                                                        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions