HTML Processor Interface
Now you’re ready to define the interface that’ll be used by the FOO language processor to emit HTML. You can define this interface as a set of generic functions because you’ll need two implementations—one that actually emits HTML and another that the html
macro can use to collect a list of actions that need to be performed, which can then be optimized and compiled into code that emits the same output in a more efficient way. I’ll call this set of generic functions the backend interface. It consists of the following eight generic functions:
(defgeneric raw-string (processor string &optional newlines-p))
(defgeneric newline (processor))
(defgeneric freshline (processor))
(defgeneric indent (processor))
(defgeneric unindent (processor))
(defgeneric toggle-indenting (processor))
(defgeneric embed-value (processor value))
(defgeneric embed-code (processor code))
While several of these functions have obvious correspondence to indenting-printer
functions, it’s important to understand that these generic functions define the abstract operations that are used by the FOO language processors and won’t always be implemented in terms of calls to the indenting-printer
functions.
That said, perhaps the easiest way to understand the semantics of these abstract operations is to look at the concrete implementations of the methods specialized on html-pretty-printer
, the class used to generate human-readable HTML.