-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Replace '~' to ' ' as a non-breaking space in bibliography.lua #1860
Conversation
Not quite. It works at shaping level, but is then rendered as a fixed-sized non-breaking space. Unicode Line Breaking Algorithm
In (La)TeX, |
Additional note on how to get a stretchable non-breaking space: In SILE, we can compute the size of an inter-word justifying space (which depends on several settings) as follows
(EDIT: of course the above is only true in a context where the current font is applied) And then we must insert a |
@Omikhleia Won't that hack give you the default size of a space but not the actual size in a given line (because it doesn't cause the line breaker to re-consider possible break points and adjust the stretch/shrink)? It seems to me we should probably supply some |
It has to be done via a command, yes, to get evaluated in the right font and break context. Then I don't think we need a special node -- we just need that command to insert a simple kern for the line-breaking not to consider it as a breakpoint. I've been running with this in various places:
And it does the right thing, it seems to me. If we want to support |
Lol, and even used here as pseudo-unit Apparently I like re-implementing those stretchable inter-word spaces in many different ways and places ;-) |
(Bad example typed with a huge emergencyStretch) First paragraph with BTW, I wouldn't call the formula a "hack" -- it's, to my best understanding, more or less how is built the inter-word glue used for regular spaces (though the logic of |
By your example, I take back the "work just fine" from my first message.
So, we can not just replace one char for another, since the space size needs to be calculated every time. Therefore, the needed change is not trivial, since there are many lines in
|
Hmm, quickly looking at the bibliography.lua code (I only dabbled there once, I don't know it very well), it assumes the content is a string in XML and just processes it: Line 101 in 7efff5b
(That's for the "cite" command, same goes for the "reference" command a bit further, etc.) So cleverly replacing the Footnotes
|
Replacing the In addition, it just comes into my mind that we may have some |
For the record, another potential solution could be to use 0x00A0 indeed, but to have it processed (replaced by a kern) in |
I'm going to go ahead and merge this as a stop-gab because having a Unicode non-breaking space is an improvement on leaking a LaTeX symbol that we don't actually process that way. That being said none of the discussion here is actually addressed and there are good ideas and even links to implementations that should be considered. I opened #1889 to track that. |
On second thought I'm bumping this past today's point release because it isn't clean to me what this is doing. This code is used to match X and either replace with nothing or split into tokens. In other words removing I'm happy to see a bug fixed, but I think I need to see an MWE that we can turn into a test before applying this. |
So I think this will make perfect sense and function as expected after #1918 lands. |
I think we need to add a test case that actually shows this is working now. These changes didn't break anything in our tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a simple test case that shows this in action (either working or not working doesn't matter) that we can build out a test from with expectations so we know when the code does what we expect?
I played around with editing the bibtex test to hit this change and couldn't come up with anything. I'm happy for it to go through but I'm concerned we may not actually have fixed anything. We need a test to prove it if nothing else so that I feel comfortable with a change log going out saying we fixed something that something has at least changed. If we don't get a working test case soon this might have to wait for the next release cycle as v0.14.14 is basically ready to go out other than waiting for this. |
I'm still quite happy to get this enhancement landed, but I'm a bit confused about what is affecting what here and we still don't have a test case that shows "this thing that didn't work as expected/desired before does now". As soon as we can come up with such a test case this can land is the next patch release, but I can't hold up the release of other verified bug fixed for something we can't even show in action—hence this getting bumped again. |
Accept `\&` for compatibility with legacy BibTeX, but do not mandate it to be escaped for compatibility with other engines. Support unescaped `~` as a non-breaking space for compability with TeX, this is often found in existing bibliography files. Support `\~` to render a tilde. XML-escape the input so it can safely be wrapped in a `<sile>` construct. Closes sile-typesetter#2050 Closes sile-typesetter#1860 (replaced by this implementation)
Accept `\&` for compatibility with legacy BibTeX, but do not mandate it to be escaped for compatibility with other engines. Support unescaped `~` as a non-breaking space for compability with TeX, this is often found in existing bibliography files. Support `\~` to render a tilde. XML-escape the input so it can safely be wrapped in a `<sile>` construct. Closes sile-typesetter#2050 Closes sile-typesetter#1860 (replaced by this implementation)
Closing this PR: |
Accept `\&` for compatibility with legacy BibTeX, but do not mandate it to be escaped for compatibility with other engines. Support unescaped `~` as a non-breaking space for compability with TeX, this is often found in existing bibliography files. Support `\~` to render a tilde. XML-escape the input so it can safely be wrapped in a `<sile>` construct. Closes sile-typesetter#2050 Closes sile-typesetter#1860 (replaced by this implementation)
Accept `\&` for compatibility with legacy BibTeX, but do not mandate it to be escaped for compatibility with other engines. Support unescaped `~` as a non-breaking space for compability with TeX, this is often found in existing bibliography files. Support `\~` to render a tilde. XML-escape the input so it can safely be wrapped in a `<sile>` construct. Closes sile-typesetter#2050 Closes sile-typesetter#1860 (replaced by this implementation)
Accept `\&` for compatibility with legacy BibTeX, but do not mandate it to be escaped for compatibility with other engines. Support unescaped `~` as a non-breaking space for compability with TeX, this is often found in existing bibliography files. Support `\~` to render a tilde. XML-escape the input so it can safely be wrapped in a `<sile>` construct. Closes sile-typesetter#2050 Closes sile-typesetter#1860 (replaced by this implementation)
The
bibtex
package, specifically thebibliography.lua
file, has functions "borrowed from nbibtex". Along it, the '~' character (which is used is used to insert a non-breaking space in latex) is used to separate author's names. However, in sile '~' is an ordinary character and, therefore, the\reference
command may produce undesired '~' symbols in the generated document.This PR changes one occurrence of '~' to ' ' (0x00A0) character, which (hack or not) works just fine in sile.
I was tempted to also replace '~' in lines 241, 243 and 244, but since I could not trigger them in my documents, I left these lines unchanged.