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
Add n-level glossing and spacing parameters #1
Conversation
leipzig-gloss.typ
Outdated
#let numbered_gloss = gloss.with(numbering: true) | ||
#let numbered_gloss = gloss.with(numbering:true) | ||
|
||
#let nogloss = " " |
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.
Is this definition doing anything?
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.
Oh I see your explanation. It'd be good to use this in an example, to justify why it is there.
Thanks a lot for adding explanatory text throughout the example document, that's a really helpful change. |
leipzig-gloss-examples.typ
Outdated
morphemes: ([#smallcaps[conn]=him], [that.#dat.#sg], [time.#dat.#sg], [eat.they.shall]), | ||
translation: "They shall celebrate him on that date", | ||
) | ||
``` |
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.
This code block needs to be updated with the actual custom values for spacing that you used.
How hard would it be to make the n-level gloss behavior a separate named function from |
leipzig-gloss.typ
Outdated
style(styles => { | ||
block(breakable: breakable)[ | ||
#stack( | ||
dir:ltr, |
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.
Mostly a note, this library needs to be able to support RTL text correctly to be useful to linguists working with Hebrew/Arabic/Farsi/etc.
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'm not super familiar with how glosses for RTL languages are formatted (the only such glosses I've personally encountered used Latin transliterations) but I can look into detecting if the surrounding text is RTL and editing things based on that. I think even as-is it should still work fine with RTL text inside the gloss (though requiring the actual lists of words for each line to list the words in LTR order) but I haven't tested 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.
I think it's fine to not try to solve RTL text in this patch, it's just something I want to keep in mind.
This is an interesting idea -- I principally implemented it as an optional argument because that's how it worked in expex, but while it would definitely take some work to separate out the nlevel functionality into a new function I think it would definitely work. Might even make the code more readable on the whole and allow for changes to be made to each function separately if something's easier for one type than another. I'd be up to separate it out into a separate function for sure if you think it's better. |
Yeah, I think it's better to optimize for readability/maintainability here, so go ahead and separate it out into a separate function. |
@betoma in the interest of fixing the most pressing bug (the numbered gloss number appearing on the wrong line), and being able to submit this as a typst package, I've manually copied some of the code and documentation improvements in this PR to the master branch. I will try to move over the rest of the improvements + implement n-level glossing as a separate function in the next several days. |
@neunenak Thanks so much for doing that! I haven't had time to fix up this code to separate out functions and such so I appreciate you grabbing the stuff that's most useful. |
A handful of changes to allow for n-level style glossing (as in expex) and the ability to configure the spacing of certain elements in the gloss.
nlevel
parameter specifying whether the gloss is using n-level style or not. Defaults to false.line_styles
parameter to allow specifying a list of styles for lines in the gloss without their own dedicated style parameter.header_text_style
andtranslation_style
parameters, corresponding to the existingsource_text_style
andmorphemes_style
parameterssource_text
andmorphemes
parameters optional, as they would not be present in an n-level style glossadditional_gloss_lines
parameter to justgloss_lines
, since for n-level glosses this is the only place gloss lines are providedgloss_lines
function tobuild_gloss
to avoid conflicts with the above parametergloss
function to use a ltr stack to display the gloss rather than using padding, allowing for the number of numbered glosses to appear on the same line as the first line of the glossbreakable
parameter to indicate whether the gloss should be allowed to break across pages. Defaults to false.gloss_padding
parameter to specify how far indented the gloss itself should beleft_padding
parameter to specify how far indented the number should be in numbered glosses. Does nothing for unnumbered glosses. Should be less thangloss_padding
since this space is included in the space specified bygloss_padding
.post_header_space
andpre_translation_space
parameters to specify how much space should appear between these elements and the gloss itselfspacing_between_items
tointerword_spacing
to more clearly distinguish its function compared to all the other spacing functionsnogloss
as a convenient alias for a space that can be used to make clear that a given item was intentionally given no corresponding text in a given gloss line