-
-
Notifications
You must be signed in to change notification settings - Fork 74
Smart Quotation Marks in Formattable Strings. #99
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
base: main
Are you sure you want to change the base?
Conversation
|
Should this also work for single quotes? The |
There is no need for that, and it might even produce problems.
So long as double quotes are part of the spec, I think it should be fine. |
|
If I'm reading your code correctly, BibTeX' normal chunks will continue to yield regular quotes. I think that we should parse BibTeX normal chunks to also emit the quote chunk so that both formats behave more similarly. |
That would be good but how do we want this to work? In Bib(la)TeX, you don't use The best way I see to do this is to make another |
|
Another thing: I do think we will run into issues at some point by just parsing everything between I think we should add support for simple typst commands like |
|
Ultimately, smart quotes are a heuristic. Typst implements it here: https://github.com/typst/typst/blob/c20b6ec6e157b753e90aa60ccd5b50f6f31cb7f6/crates/typst/src/text/smartquote.rs#L91. This handles something like quotes between numbers (e.g. for measurements in inches). It could be worthwhile to extract this into a crate and use the same code here and there. Additionally, I would propose to tokenize only the quote inside a chunk instead of the complete citation it wraps and approach this as purely string replacement instead of semantic. Adding a non-standard chunk to |
PgBiel
left a comment
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.
Thanks! Overall, mostly fine. I can apply most of my suggestions myself, but I still have a few concerns which will need a bit of additional discussion.
| <<==== MODE ====<< | ||
|
|
||
| >>==== RESULT ====>> | ||
| Nation of “Positive Obligations “ of State under the European Convention on Human Rights (1) |
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.
Interesting that the original test, which expected " at both positions, failed. I wonder if Hayagriva is just doing something that citeproc deliberately isn't? Can we find a reason for this to see if it is reasonable to override the test like that?
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.
On main the test passes. Hayagriva handles this correctly (aside from this branch using fancy quotation marks)
| Title and sentence case folding will always be deactivated if your item has set | ||
| the `language` key to something other than English. | ||
|
|
||
| Double quotation marks in a formattable string will be we transformed to |
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.
I do wonder if Typst should somehow wrap this in a smartquotes elements, which would render your changes potentially problematic... I'll try to ask the rest of the team on this.
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.
After some initial discussion with part of the team, it's possible that we could want the smartquoter to emit an ElemChild::SmartQuote so that Typst can later emit a smartquote element, which would allow customization via show and set rules. The idea is then that the default plain text renderer would just convert it into text with the surrounding quotes. In addition, the chosen quotes stored in that element would be None if the CSL locale doesn't override the quote terms to allow for set rules to work on the Typst side.
However, we're still not sure regarding the algorithm. We would like to know how BibLaTeX approaches smart quoting so we can make sure existing .bib files behave at least somewhat as expected, converting one approach to another if necessary. It could be nice to have some further investigation in this regard.
Still, we won't make a decision before feedback from @reknih (who is currently unavailable), so don't worry about making too many changes right now, although feel free to investigate about BibLaTeX as that would be helpful.
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.
Sounds good.
I already looked into how biblatex does this; I‘ll write it up some time next week
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.
Biblatex does not handle " in any special way. For quotation marks, they provide the \mkbibquote command, which either produces American quotation marks (and, typically, moves punctuation like . or , inside the quote) or uses \enquote by the csquotes packages. The latter uses language-dependent quotation marks.
For conversion, we could translate \mkbibquote and \enquote to use normal quotation marks, which are then handled by hayagriva.
Co-authored-by: PgBiel <[email protected]>
Close #70.
I implemented a couple of changes to enable hayagriva to better render quotation marks in titles or other formattable strings.
The changes are:
When pushing a string to the buffer, we modify the string with the same heuristics as typst uses for smart quotes (taking into account any surrounding quotes created by hayagriva). To generate the quotation marks we add, we use the given style and language.
Changes in passing tests
Adds 6 tests to passing but removes one: With the new changing of quotation marks, we change
flipflop_OrphanQuoteto a slightly different local test.Todo:
Todo in
biblatex:\enquote,\mkbibquote)Todo in
typst:SmartQuoterto its own crate, or a util crate usable by typst and hayagriva