Add special handling of the DocBook trademark tag.
Each trademark will only have a trademark symbol appended the first time in a document for print / html, and the first time on each HTML page for html-split. It is possible to always append the trademark symbol for a trademark, by setting the role attribute to "force" in the trademark tag. The code differentiates between trademarks in normal text and titles, so if there is a trademark in a title, the symbol will be displayed the first time in the title, and the first time in the normal text. Basically this means that all trademarks can / should be marked up in the documents, and the stylesheet will do "the right thing". Looked at by: murray Approved by: mwlucas (temp mentor)
This commit is contained in:
parent
426a71063e
commit
fbc02a2044
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=17939
1 changed files with 84 additions and 0 deletions
|
@ -232,6 +232,26 @@
|
|||
(literal "``")
|
||||
(process-children)
|
||||
(literal "''")))
|
||||
|
||||
;; The special FreeBSD version of the trademark tag handling.
|
||||
;; This function was more or less taken from the DocBook DSSSL
|
||||
;; stylesheets by Norman Walsh.
|
||||
(element trademark
|
||||
(if (show-tm-symbol? (current-node))
|
||||
(make sequence
|
||||
($charseq$)
|
||||
(cond
|
||||
((equal? (attribute-string "class") (normalize "copyright"))
|
||||
(make entity-ref name: "copy"))
|
||||
((equal? (attribute-string "class") (normalize "registered"))
|
||||
(make entity-ref name: "reg"))
|
||||
((equal? (attribute-string "class") (normalize "service"))
|
||||
(make element gi: "SUP"
|
||||
(literal "SM")))
|
||||
(else
|
||||
(make entity-ref name: "#8482"))))
|
||||
($charseq$)))
|
||||
|
||||
]]>
|
||||
|
||||
<!-- HTML with images ............................................ -->
|
||||
|
@ -669,6 +689,29 @@
|
|||
scale: graphic-scale
|
||||
display?: display
|
||||
display-alignment: graphic-align)))
|
||||
|
||||
;; The special FreeBSD version of the trademark tag handling.
|
||||
;; This function was more or less taken from the DocBook DSSSL
|
||||
;; stylesheets by Norman Walsh.
|
||||
(element trademark
|
||||
(if (show-tm-symbol? (current-node))
|
||||
(make sequence
|
||||
($charseq$)
|
||||
(cond
|
||||
((equal? (attribute-string "class") (normalize "copyright"))
|
||||
(literal "\copyright-sign;"))
|
||||
((equal? (attribute-string "class") (normalize "registered"))
|
||||
(literal "\registered-sign;"))
|
||||
((equal? (attribute-string "class") (normalize "service"))
|
||||
($ss-seq$ + (literal "SM")))
|
||||
(else
|
||||
(literal "\trade-mark-sign;"))))
|
||||
($charseq$)))
|
||||
|
||||
;; Make the trademark functions think print output has chunks.
|
||||
(define (chunk-parent nd)
|
||||
(sgml-root-element nd))
|
||||
|
||||
]]>
|
||||
|
||||
<![ %output.print.pdf; [
|
||||
|
@ -937,6 +980,47 @@
|
|||
attributes: attrlist
|
||||
target)
|
||||
target))
|
||||
|
||||
;; Standard boolean XNOR (NOT Exclusive OR).
|
||||
(define (xnor x y)
|
||||
(or (and x y)
|
||||
(and (not x) (not y))))
|
||||
|
||||
;; Standard boolean XOR (Exclusive OR).
|
||||
(define (xor x y)
|
||||
(not (xnor x y)))
|
||||
|
||||
;; Determine if a given node is in a title.
|
||||
(define (is-in-title? node)
|
||||
(has-ancestor-member? node (list (normalize "title"))))
|
||||
|
||||
;; Number of references to a trademark before the current
|
||||
;; reference in each chunk. Trademarks in title tags, and
|
||||
;; trademarks in normal text (actually just text that is not in
|
||||
;; title tags) are counted separately.
|
||||
(define ($chunk-trademark-number$ trademark)
|
||||
(let* ((trademarks (select-elements
|
||||
(descendants (chunk-parent trademark))
|
||||
(normalize "trademark"))))
|
||||
(let loop ((nl trademarks) (num 1))
|
||||
(if (node-list-empty? nl)
|
||||
num
|
||||
(if (node-list=? (node-list-first nl) trademark)
|
||||
num
|
||||
(if (and (string=? (data trademark)
|
||||
(data (node-list-first nl)))
|
||||
(xnor (is-in-title? trademark)
|
||||
(is-in-title? (node-list-first nl))))
|
||||
(loop (node-list-rest nl) (+ num 1))
|
||||
(loop (node-list-rest nl) num)))))))
|
||||
|
||||
;; Determine if we should show a trademark symbol. Either in
|
||||
;; first occurrence in the proper context, or if the role
|
||||
;; attribute is set to force.
|
||||
(define (show-tm-symbol? trademark)
|
||||
(or (= ($chunk-trademark-number$ trademark) 1)
|
||||
(equal? (attribute-string (normalize "role") trademark) "force")))
|
||||
|
||||
</style-specification-body>
|
||||
</style-specification>
|
||||
|
||||
|
|
Loading…
Reference in a new issue