Index: code-docs/pollen.scrbl ================================================================== --- code-docs/pollen.scrbl +++ code-docs/pollen.scrbl @@ -187,26 +187,26 @@ ◊say["Tavi"]{You also write fiction, or you used to. Do you still?} ◊say["Lorde"]{The thing is, when I write now, it comes out as songs.} } }| -@defproc[(index [heading string?] [elements xexpr?] ...) txexpr?] +@defproc[(index [#:key key string? ""] [elements xexpr?] ...) txexpr?] -Creates an entry in the keyword index under @racket[_heading] that points back to this spot in the -document. If @racket[_elements] is not empty, the web edition of the document will use it as the -contents of an understated hyperlink to back to @racket[_heading] in the keyword index. +Creates a bidirectional link between this spot in the document and an entry in the keyword index +under @racket[_key]. If @racket[_key] is not supplied, the string contents of @racket[_elements] are +used as the key. The example below will create two index entries, one under the heading “compassion” and one under the heading “cats”: @codeblock|{ #lang pollen “I have a theory which I suspect is rather immoral,” Smiley went on, more lightly. “Each of us has only a quantum of - ◊index["compassion"]{compassion}. That if we lavish our concern - on every stray ◊index["cats"] cat we never get to the centre of + ◊index{compassion}. That if we lavish our concern on every + stray ◊index[#:key "cats"]{cat} we never get to the centre of things. What do you think of it?” }| @defproc[(note [#:date date-str non-empty-string?] [#:author author string? ""] Index: pollen.rkt ================================================================== --- pollen.rkt +++ pollen.rkt @@ -94,11 +94,11 @@ (poly-branch-tag section) (poly-branch-tag subsection) (poly-branch-tag code) (poly-branch-tag dialogue) (poly-branch-tag say) -(poly-branch-tag index) +(poly-branch-kwargs-tag index) (poly-branch-tag figure) (poly-branch-tag figure-@2x) (poly-branch-kwargs-tag blockcode) (poly-branch-kwargs-tag verse) ; [#:title ""] [#:italic "no"] Index: tags-html.rkt ================================================================== --- tags-html.rkt +++ tags-html.rkt @@ -102,16 +102,17 @@ (define file (or (assoc 'filename attrs) "")) (define codeblock `(pre [[class "code"]] (code ,@elems))) (cond [(string>? file "") `(@ (div [[class "listing-filename"]] 128196 " " ,file) ,codeblock)] [else codeblock])) -(define (html-index . elems) - `(a [[id ,(here-id (list "_idx-" (uri-encode (car elems))))] - [href ,(string-append "/keyword-index.html#" (uri-encode (string-downcase (car elems))))] - [data-index-entry ,(car elems)] +(define (html-index attrs elems) + (define index-key (maybe-attr 'key attrs (tx-strs `(span ,@elems)))) + `(a [[id ,(here-id (list "_idx-" (uri-encode index-key)))] + [href ,(string-append "/keyword-index.html#" (uri-encode (string-downcase index-key)))] + [data-index-entry ,index-key] [class "index-link"]] - ,@(cdr elems))) + ,@elems)) (define (html-say . elems) `(@ (dt ,(car elems) (span [[class "x"]] ": ")) (dd ,@(cdr elems)))) (define (html-verse attrs elems)