4. Scribe Programming Manual -- Scribe Library

4. Scribe Programming Manual -- Scribe Library

Browsing

Home: Scribe Programming Manual

Previous chapter: Common Classes
Next chapter: Container numbering

Scribe Library

4.1 Node
4.2 Text
4.3 Container
4.9 Reference
4.10 Images
4.11 Target format

Chapters

1. Defining new functions
2. Fontification
3. Common Classes
4. Scribe Library
5. Container numbering
6. Target format
7. Programming Back-ends
8. The HTML back end
9. The LaTeX back end
10. The MAN back end
11. Bibliography
12. Embedding Scribe into Bigloo
13. Scribe Apache module
14. Classes, Functions and Variables
15. Bibliography

Scribe

Home page:Scribe

Documentation:user
expert
styles

This chapter describes the functions provided by Scribe that can be used to retrieve informations about the current document and nodes that are processed. These functions are available to Scribe documents. That is with the Standard Library functions they compose the set of the whole Scribe user functions.

Introspection facilities are mostly useful in order to implement Scribe styles. It may happens that a style need informations about the document structure, which chapter comes next, etc. The style used to render the HTML of this manual uses the facilities to implement the left margin. For instance, this part of the text contains references to the previous and next chapters in the manual. For the sake of the example, here is the source code that implement the left margin:

(define (local-margin)
  (let ((c (current-chapter)))
    (if c
        (let* ((title (ctitle c "Sections"))
               (prev (chapter-previous (current-chapter)))
               (next (chapter-next (current-chapter)))
               (dtitle (document-title (current-document)))
               (items (if next
                          (list (list (bold "Previous: ")))
                          '()))
               (items (if prev
                          (cons (list (bold "Next: ")
                                      (ref :chapter prev))
                                items)
                          items))
               (rhome (tr (th :align 'left :valign 'top "Home: ")
                          (td :align 'right (ref :url (document-file (current-document)) dtitle))))
               (rnext (tr (th :align 'left :valign 'top "Next chapter: ")
                          (td :align 'right
                              (if next
                                  (ref :chapter next)
                                  ""))))
               (rprev (tr (th :align 'left :valign 'top "Previous chapter: ")
                          (td :align 'right
                              (if prev
                                  (ref :chapter prev)
                                  ""))))
               (browse (section :title "Browsing" :toc #f :number #f
                                (table :width 1.
                                       rhome
                                       (tr (td (linebreak 1)))
                                       rprev
                                       rnext
                                 (tr (td (linebreak 1)))))))
          (if (pair? (chapter-children c))
              (list browse
                    (section :title title :toc #f :number #f
                             (table-of-contents :chapter #f :subsection #t)))
              browse))
        "")))

(define (ctitle c . def)
  (if (string? (chapter-title c))
      (chapter-title c)
      (if (string? (chapter-subtitle c))
          (chapter-subtitle c)
          (car def))))

In this chapter we present the functions used in that example.

4.1 Node

(node-hook::procedure . proc)Scribe function

If the argument proc is provided, node-hook installs a hook on node creation. Otherwise, it returns the current installed node hook. A node hook is a function that is called each time a node is built. The hook is passed the newly constructed node when invoked.


4.2 Text

(text?::pair-nil ::obj)Scribe function

Returns #t if obj is a text. It returns #f otherwise.


(text-body::pair-nil ::%document)Scribe function

Returns the list of node in the text.


4.3 Container

(container-hook::procedure . proc)Scribe function

If the argument proc is provided, container-hook installs a hook on container creation. Otherwise, it returns the current installed container hook. A container hook is a function that is called each time a container is built. The hook is passed the newly constructed container when invoked. At creation time, if both container-hook and node-hook are specified, the newly created container is first passed to the container-hook then to the node-hook.


(generic container-file ::%container)Scribe function

Returns the file the %container is compiled to.


4.4 Document

(document-hook::procedure . proc)Scribe function

If the argument proc is provided, document-hook installs a hook on document creation. Otherwise, it returns the current installed document hook. A document hook is a function that is called each time a document is built. The hook is passed the newly constructed document when invoked. At creation time, if document-hook, container-hook, and node-hook are specified, the newly created document is first passed to the document-hook then to the container-hook and then eventually to the node-hook.


(current-document::%document)Scribe function

Returns a pointer to the document being processed.


(with-document ::%document ::procedure)Scribe function

Invokes the procedure in argument in the context where current-document is document.


(document?::pair-nil ::obj)Scribe function

Returns #t if obj is a document. It returns #f otherwise.


(document-chapters::pair-nil ::%document)Scribe function

Returns the list of chapters in the document.


(document-sections::pair-nil ::%document)Scribe function

The list of sections of the document that are not embedded in any chapter.


(document-sections*::pair-nil ::%document)Scribe function

The list whole of sections of the document. This list contains the sections that not embedded in any chapter and also those contained in chapters.


(document-title::bstring ::%document)Scribe function

The title of the document.


(document-file ::%document)Scribe function

The file where to compile the document.


4.5 Chapter

(current-chapter::%chapter)Scribe function

Returns a pointer to the chapter being processed.


(with-chapter ::%chapter ::procedure)Scribe function

Invokes the procedure in argument in the context where current-chapter is chapter.


(chapter?::pair-nil ::obj)Scribe function

Returns #t if obj is a chapter. It returns #f otherwise.


(chapter-sections::pair-nil ::%chapter)Scribe function

The list of sections of the chapter.


(chapter-title::bstring ::%chapter)Scribe function

The title of the chapter. This may be #f if the chapter has a subtitle.


(chapter-subtitle::bstring ::%chapter)Scribe function

The subtitle of the chapter. This may be #f if the chapter has a title.


(chapter-children ::%chapter)Scribe function

The list of block in the chapter.


(chapter-file ::%chapter)Scribe function

A boolean value that is used by some back-end (such as the HTML back-end) to decide if the chapter must be compiled into a separate target.


(chapter-next ::%chapter)Scribe function

The next chapter in the document the chapter belongs to.


(chapter-previous ::%chapter)Scribe function

The previous chapter in the document the chapter belongs to.


*scribe-chapter-numbering*Scribe variable

See chapter Container numbering.


4.6 Section

(current-section::%section)Scribe function

Returns a pointer to the section being processed.


(with-section ::%section ::procedure)Scribe function

Invokes the procedure in argument in the context where current-section is chapter.


(section?::pair-nil ::obj)Scribe function

Returns #t if obj is a section. It returns #f otherwise.


(section-title::bstring ::%section)Scribe function

The title of the section.


(section-subsections::pair-nil ::%section)Scribe function

The list of the subsection in the section.


*scribe-section-numbering*Scribe variable

See chapter Container numbering.


4.7 Subsection

(subsection?::pair-nil ::obj)Scribe function

Returns #t if obj is a subsection. It returns #f otherwise.


(subsection-title::bstring ::%subsection)Scribe function

The title of the subsection.


(subsection-subsubsections::pair-nil ::%subsection)Scribe function

The list of the subsubsection in the subsection.


*scribe-subsection-numbering*Scribe variable

See chapter Container numbering.


4.8 Subsubsection

(subsubsection?::pair-nil ::obj)Scribe function

Returns #t if obj is a subsubsection. It returns #f otherwise.


(subsubsection-title::bstring ::%subsubsection)Scribe function

The title of the subsubsection.


*scribe-subsubsection-numbering*Scribe variable

See chapter Container numbering.


4.9 Reference

(generic find-reference ::obj ::%document)Scribe function

Find the reference obj in the document. If the argument obj is a string. The function find-reference searches for all possible references in document. If the argument is a reference the search is restricted to a subset of all references, such as chapter-ref or mark-ref.


4.10 Images

(convert-image ::bstring ::bstring)Scribe function

Convert an image from another format to another. This function is called by all the back-end in order to convert images into supported format. If the two image names are equal, this function applies no conversion. If they differ, it invokes the function held by the user variable *scribe-convert-image*.


*scribe-convert-image*Scribe variable

The value of this variable is a function accepting two arguments, the name of the image to be converted and the name of the image to be produced. The standard definition of this variable is:

(define (*scribe-convert-image* from to)
   (let ((cmd (if (string=? (suffix from) "fig")
                 (string-append "fig2dev -L " (suffix to) " " from " > " to)
                 (string-append "convert " from " " to))))
      (if (=fx (system cmd) 0) to #f)))


4.11 Target format

(scribe-format? ::symbol)Scribe function

See chapter Target format.


*scribe-format*Scribe variable

See chapter Target format.



This page has been generated by Scribe.
Last update Wed Dec 18 09:23:03 2002