-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Overhaul indexer #2207
base: master
Are you sure you want to change the base?
Overhaul indexer #2207
Conversation
3f9a15c
to
ad671c8
Compare
c9eea37
to
e262509
Compare
3f412d6
to
d91b1dc
Compare
d91b1dc
to
e272e43
Compare
I'm not sure if it's a side effect of something else I've done, but this appears to print the index in a monospaced font. |
It always did^^ |
7e7769a
to
facf84c
Compare
As for table of contents, use an intermediary file, so the index(es) may be used (at the cost of a SILE re-run) anywhere, and not only on their own page at the end of a document...
fed91fe
to
808aaf4
Compare
I've copied the file into my project and am using it there until it's part of a release (yay for modularity!). It seems to be working nicely. Ideally I'd want to be able to split index entries into letter headings and make it use a two-column layout, but I think the latter is independent of this package (though I'm struggling to make it work) and the latter is not vital (and maybe can be done in the style hook?). Thanks! |
Thanks, glad it's helpful.
I actually wanted the same, but problem is that we don't have enough ICU support for that. Checking for differences on the first character to insert a "letter milestone" is not sufficient: E.g. In French "Éric" and "Ethan" should possibly both be under E, not under E and É). It might be doable with ICU (diacritic removal, via a transform
--> On such a topic, a dedicated issue would be required, and one would have to check the literature, regarding how this is addressed in general. (EDIT:
Wholly independent from this package indeed (and we don't really have robust multicolumn layouts yet). Footnotes
|
For the sectioning, a hook that provides the name of the current and previous (empty string / nil for the first one) and lets you return nothing or a line break, with per-language defaults and a warning if your language didn't have one would probably be a nice start. The implementation for English is fairly simple but, as you say, for others it can be different (for some languages, I suspect, it's trivial because there's no equivalent notion and everything ends up in a single section). |
As said, wait for this to PR to be finished, reviewed and merged, and feel free to discuss and propose something... (But as far as I am concerned, I'd be against any hook that works only for English.) |
The new implementation was no longer callable from SIL or XML as the pages are now an AST (with links etc.), so a command is no longer meaningful and it's best to have it as a package method.
Such textual reconstructions from typeset nodes were performed differently in the tableofcontents and indexer packages, and possibly elsewhere. The logic is tied to the typeset nodes and typesetter internal states, so it's better moved there.
554424d
to
5c60ce2
Compare
@alerque Ready for review. |
@Omikhleia If you tell me exactly what function(s) you want exposed (preferably from icu4x) I can expose it to Lua via the |
@davidchisnall A hook is fine if we can come up with something we think will have wide utility, but this doesn't sound like a robust way to define such a hook. Also if the current implementation has a callback function for outputting each line, implementing such a sectioning device yourself should be trivial. Just stash the last entry in a local variable (instantiated outside the function) and check it at the top of the function when outputting an entry and output a header first if desired. This is quite a common paradigm for extending/changing SILE behavior already and doesn't require the default implementation to have any hooks or anything. You can even re-use the existing function by stashing it first, then just add your section handling to a new function and call back to the original one. |
@Omikhleia You mention this as breakage, but it doesn't sound to me like something we need to hold off on for a major release bump since I would consider the existing weird styling a bug not a feature. What you you think? I'm targeting this for the next minor (patch level since we're stuck in ZeroVer mode) release unless I hear suggestion to the contrary. |
Oh yes of course, as long as it's still marked experimental I wouldn't even consider making a breaking release for changes. Just change it for the better and hope for the best ;-) I agree it probably hasn't seen much use. My own projects have their own implementations (two of them I see). I'll have to work on bringing them in closer to the source by basing on and extending this. That will help get it some exercise and also make it easier to contribute improvements. In the mean time I see no reason not to move ahead with this sooner rather than later. We can even consider removing the experimental tag after this PR (anytime before the release or whatever release follows when we decide the usage should be considered somewhat stable). |
Closes #1339
none
(all pages are listed without page range collapsing) orexpanded
(consecutive pages are collapsed in full, e.g. 301-305)pdf
package is previously loadedminimal
/minimal-two
for page range collapsing = consecutive pages are collapsed in minimal ranges (e.g. 301-5) or minimal ranges with at least two digits (e.g. 301-05). N.B. the "minimal", "minimal-two" and "expanded" names are loosely derived from those defined in CSL.1dotfill
(leaders) (default),fill
(space as before),comma
(content is not line-flushed). These are the most usual ways of presenting an index, i.e.item . . . . . 50, 60-63
item 50, 60-63
item, 50, 60-63
may be used (at the cost of a SILE re-run) anywhere, and not only on their own page at the end of a document... (This does fix several items from Enhancing the indexer package #1339, notably lost index entries if there's no page break before the
\printindex
and index entries are on that page2)index:item
into an indexer package method = It's no longer callable from SIL/XML, so a package method is certainly better than a command.Footnotes
For some consistency, although indexes are not related to CSL. Note that some language may prefer a certain format (e.g. French typography rules usually recommend full expanded ranges, while English rules may prefer a minimal variant), but the package leaves that decision to the user. ↩
It's also more general towards supporting indexes that are not at the end of document on their own pages. I do have cases for indexes early in the document (as for table of contents, one may want them this way, in some books...). Reading the index from an intermediary files also allows for other packages to use it (e.g. one could implement a fancyindex as as did for the ToC in fancytoc.sile, and do their own rendering based on another logic while reusing most of the "common" code) ↩
As noted in the commit log, there are good reasons to do that (I always was convinced of it, at least! Doh)... @davidchisnall Just for the notice, I'll need to backport that to resilient's (actually silex's) modified typesetter, if that proposed change is accepted. ↩