Instead of this:
I would prefer it to show as: 28-35
.
Instead of this:
I would prefer it to show as: 28-35
.
There is no builtin mechanism, and I think one would need to use scheme to do it via \extern. I’ve tried briefly but didn’t got anything, I need to think a bit more about it.
Merge this patch into progs/utils/cite/cite-sort.scm
28a29,38
> (define (cite-keys-inc? t1 t2)
> (let*
> ((t1 (car t1))
> (t2 (car t2))
> (s1 (if (string? t1) t1 (convert t1 "stm-snippet" "verbatim-snippet")))
> (s2 (if (string? t2) t2 (convert t2 "stm-snippet" "verbatim-snippet"))))
> (if (and (string->number s1) (string->number s2))
> (== 1 (- (string->number s2) (string->number s1)))
> #f)))
>
33a44,60
> (define (merge-contiguous new old present)
> (let ((flush (lambda ()
> ;;(display* "present: " present "\n")
> (if (> (length present) 2)
> (list (list (caar present) `(concat ,@(cdar present) "-" ,@(cdAr present))))
> present))))
> (if (null? old)
> (if (null? present)
> new
> (append new (flush)))
> (if (null? present)
> (merge-contiguous new (cdr old) (list (car old)))
> (if (cite-keys-inc? (cAr present) (car old))
> (merge-contiguous new (cdr old) (append present (list (car old))))
> (merge-contiguous (append new (flush)) (cdr old) (list (car old)))
> )))))
>
42,44c69,76
< ;; we should merge contiguous number series here...
< (sorted-args (map cadr sorted-tup))
< (ret `(concat ,@(list-intersperse sorted-args '(cite-sep)))))
---
> (merged-tup (merge-contiguous '() sorted-tup '()))
> (merged-args (map cadr merged-tup))
> (ret `(concat ,@(list-intersperse merged-args '(cite-sep))))
> )
> ;;(display* "merged-tup: " merged-tup "\n")
> ;;(display* "merged-args: " merged-args "\n")
> ;;(display* "tup: " tup "\n")
> ;;(display* "ret: " ret "\n")
This mechanism is integrated in mogan 1.2.0 version. If you are using beta version of mogan, enable cite-sort
style package, then citations is sorted and merged. please give us your feedback.
Looks good, thanks!
But I’m wondering why you make it a package? This process is pretty simple and far from resource intensive, cause it only gets invoked when users update their buffer. It would be weird such a functionality isn’t by default enabled.
Because in digital document, there are hyperlinks on each citation numbers, which should not be collapsed into a range mark.