+(defun hfy-begin-span (style text-block text-id text-begins-block-p)
+ "Default handler to begin a span of text.
+Insert \"<span class=\"STYLE\" ...>\". See
+`hfy-begin-span-handler' for more information."
+ (when text-begins-block-p
+ (insert
+ (format "<span onclick=\"toggle_invis('%s');\">…</span>" text-block)))
+
+ (insert
+ (if text-block
+ (format "<span class=\"%s\" id=\"%s-%d\">" style text-block text-id)
+ (format "<span class=\"%s\">" style))))
+
+(defun hfy-end-span ()
+ "Default handler to end a span of text.
+Insert \"</span>\". See `hfy-end-span-handler' for more
+information."
+ (insert "</span>"))
+
+(defvar hfy-begin-span-handler 'hfy-begin-span
+ "Handler to begin a span of text.
+The signature of the handler is \(lambda (STYLE TEXT-BLOCK
+TEXT-ID TEXT-BEGINS-BLOCK-P) ...\). The handler must insert
+appropriate tags to begin a span of text.
+
+STYLE is the name of the style that begins at point. It is
+derived from the face attributes as part of `hfy-face-to-css'
+callback. The other arguments TEXT-BLOCK, TEXT-ID,
+TEXT-BEGINS-BLOCK-P are non-nil only if the buffer contains
+invisible text.
+
+TEXT-BLOCK is a string that identifies a single chunk of visible
+or invisible text of which the current position is a part. For
+visible portions, it's value is \"nil\". For invisible portions,
+it's value is computed as part of `hfy-invisible-name'.
+
+TEXT-ID marks a unique position within a block. It is set to
+value of `point' at the current buffer position.
+
+TEXT-BEGINS-BLOCK-P is a boolean and is non-nil if the current
+span also begins a invisible portion of text.
+
+An implementation can use TEXT-BLOCK, TEXT-ID,
+TEXT-BEGINS-BLOCK-P to implement fold/unfold-on-mouse-click like
+behavior.
+
+The default handler is `hfy-begin-span'.")
+
+(defvar hfy-end-span-handler 'hfy-end-span
+ "Handler to end a span of text.
+The signature of the handler is \(lambda () ...\). The handler
+must insert appropriate tags to end a span of text.
+
+The default handler is `hfy-end-span'.")
+