markup-region-event

built-in data type

Purpose

A markup-region-event triggers a rule when encountered by do markup-parse in a markup source. It is a markup-event that includes content; the most common example is an element with data content. A markup-region-event can be signalled as an argument of a pair of catch labels:

A markup region always starts with a #markup-start signal, and ends with a #markup-end signal. The markup-region-event argument of a pair of signals must be reference-equal. All data between the #markup-start and #markup-end signals is the markup region's content.

markup-region-event is an abstract type; its subtypes are used in specific contexts. For example,

  • elements are represented by instances of markup-element-event, and
  • comments are represented by instances of markup-comment-event.

If a rule is fired from a markup region (using do markup-parse) the markup-region-event will be available from the rule as #current-markup-event, and the region's content as #content.

Example

Function wrap-content produces a new markup source from the markup source argument region-content and the markup-region-event argument region-boundary. The two arguments are combined into a new markup region, where region-content forms its content.

  define markup source function
     wrap-content           value markup source       region-content
                  in-region value markup-region-event region-boundary
  as
     signal throw #markup-start region-boundary
     output region-content
     signal throw #markup-end region-boundary
  
  
  ; This process rule prepares a markup-region-event for wrapping content.
  
  global markup-region-event root-element
  process
     using group "capture root element"
     do xml-parse scan "<wrapper/>"
        suppress
     done
  
  
  ; This process rule demonstrates a use of wrap-content
  
  process
     do xml-parse scan #main-input
        using group "process wrapped document"
        do markup-parse wrap-content #content in-region root-element
           output "%c"
        done
     done
  
  
  group "capture root element"
  element #implied
     set root-element to #current-markup-event
     suppress
  
  group "process wrapped document"
  element #implied
     output "<%q>%c></%q>%n"