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

Cite command is sensitive to screensize, but IMHO shouldn't be. #5647

Open
fingolfin opened this issue Feb 20, 2024 · 2 comments
Open

Cite command is sensitive to screensize, but IMHO shouldn't be. #5647

fingolfin opened this issue Feb 20, 2024 · 2 comments

Comments

@fingolfin
Copy link
Member

The output of Cite differs with the terminal width. This affects all of it, but is particularly bad for the bibtex entry.

Compare:

gap> SizeScreen();
[ 116, 62 ]
gap> Cite("smallgrp");
....
BibTeX:

@misc{ SmallGrp1.5.3,
  author =           {Besche, H. U. and Eick, B. and O'Brien, E. and Horn, M.},
  title =            {{SmallGrp}, The GAP Small Groups Library, {V}ersion 1.5.3},
  month =            {May},
  year =             {2023},
  note =             {GAP package},
  howpublished =     {\href                                           {https://gap-packages.github.io/smallgrp/}
                      {\texttt{https://gap\texttt{\symbol{45}}packages.github.io/}\discretionary
                      {}{}{}\texttt{smallgrp/}}},
  printedkey =       {BEOH23}
}

versus

gap> SizeScreen([80]);
[ 80, 62 ]
gap> Cite("smallgrp");
...
BibTeX:

@misc{ SmallGrp1.5.3,
  author =           {Besche,  H.  U. and Eick, B. and O'Brien, E. and Horn,
                      M.},
  title =            {{SmallGrp},  The  GAP  Small Groups Library, {V}ersion
                      1.5.3},
  month =            {May},
  year =             {2023},
  note =             {GAP package},
  howpublished =     {\href       {https://gap-packages.github.io/smallgrp/}
                      {\texttt{https://gap\texttt{\symbol{45}}packages.github.\
io/}\discretionary
                      {}{}{}\texttt{smallgrp/}}},
  printedkey =       {BEOH23}
}

I would suggest to modify Cite so that it completely ignores the terminal width. Then each bibtex key/value pair would be on a single (possibly long) line -- that's how I want it, and anyone else can wrap it to something that makes sense in their .bib file (as opposed to their terminal)

Also, what's with the weird spacing between \href and {???

@ChrisJefferson
Copy link
Contributor

One problem with not wrapping is then GAP's output is going to put \ in when it linewraps itself (which I see it doing above anyway in the how-published :( ). We should temporarily turn off formatting while printing the bibtex -- as then we should produce something which will cleanly cut+paste?

@frankluebeck
Copy link
Member

In general it seems useful to me that the function uses FormatParagraph to adjust the output to the users screen width. The main problems which can occur are long URLs without an opportunity for line breaks.

The Cite function could use PrintFormattedString to print such overlong lines in a cut-and-paste friendly manner, e.g.,

--- a/lib/package.gi
+++ b/lib/package.gi
@@ -2908,16 +2908,18 @@ InstallGlobalFunction( Cite, function(arg)
         "to cite ", en(name), " version from this installation\n\n");
 
   Print("Text:\n\n");
-  Print( en(StringBibXMLEntry( parse.entries[1], "Text" )) );
+  PrintFormattedString( en(StringBibXMLEntry( parse.entries[1], "Text" )) );
 
   Print("HTML:\n\n");
-  Print( en(StringBibXMLEntry( parse.entries[1], "HTML" )) );
+  PrintFormattedString( en(StringBibXMLEntry( parse.entries[1], "HTML" )) );
 
   Print("BibXML:\n\n");
-  Print( en(bib), "\n\n" );
+  PrintFormattedString( en(bib));
+  Print("\n\n" );
 
   Print("BibTeX:\n\n");
-  Print( en(StringBibXMLEntry( parse.entries[1], "BibTeX" )), "\n" );
+  PrintFormattedString( en(StringBibXMLEntry( parse.entries[1], "BibTeX" )));
+  Print("\n" );

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

3 participants