- { %pages multi.page.check
-% { "pages" pages n.dashify tie.or.space.connect }
-% { "page" pages tie.or.space.connect }
-% if$
- pages n.dashify
+ {
+% j is positive if pages contains a comma
+% (not fully implemented)
+ #0 'j :=
+ pages n.dashify duplicate$ 't :=
+ { duplicate$ empty$ not }
+ {
+ duplicate$ #1 #1 substring$ duplicate$
+ "{" =
+ { j #1 + 'j := }
+ 'skip$
+ if$
+ "}" =
+ { j #1 - 'j := }
+ 'skip$
+ if$
+ duplicate$ #1 #2 substring$ ", " =
+ { j j #0 = + 'j := }
+ 'skip$
+ if$
+ #2 global.max$ substring$
+ }
+ while$
+ { t empty$ not }
+ { t #1 #2 substring$ "--" = j not and
+ { t #3 global.max$ substring$ 't :=
+ duplicate$ num.chars 'i :=
+ "--" *
+ i t num.chars =
+ { { i #2 > }
+ { duplicate$ #1 i #2 - substring$
+ t #1 i #2 - substring$ =
+ { t i #1 - global.max$ substring$ * "" 't := #2 'i := }
+ { i #1 - 'i := }
+ if$
+ }
+ while$
+ }
+ 'skip$
+ if$
+ }
+ { t #1 #1 substring$ duplicate$ "," = swap$ "-" = or j and
+ { "+" * "" 't := }
+ { t #1 #1 substring$ *
+ t #2 global.max$ substring$ 't :=
+ }
+ if$
+ }
+ if$
+ }
+ while$