pre_section
Types
Once we’ve identified where the custom opening/closing tags exist in the document, we’ll separate the document into “sections”; a section will either be a custom tag that we’ll transform into HTML, or a fragment of text that does not contain any custom tags. It’s called a “raw” section because we’ve only done minimal parsing so far, and are going to parse each “RawSection” to create a “Section” with more specific attributes.
pub type RawSection {
RawTextSection(text: String, start: Int, end: Int)
RawTagSection(tag: RawTag)
}
Constructors
-
RawTextSection(text: String, start: Int, end: Int)
-
RawTagSection(tag: RawTag)
This represents the start/end of a custom tag. For example, this may be
used to identify where a
pub type RawTag {
RawTag(
name: String,
start: Int,
end: Int,
is_closing_tag: Bool,
is_self_closing_tag: Bool,
attrs_text: String,
)
}
Constructors
-
RawTag( name: String, start: Int, end: Int, is_closing_tag: Bool, is_self_closing_tag: Bool, attrs_text: String, )
Functions
pub fn get_raw_sections(
s: String,
custom_tag_names: Set(String),
) -> Result(List(RawSection), TaggError)
Divide the HTML document into Text or Tag sections. Identifying each “section” comes after we’ve identified where the custom tags exist in the document.
A Text section is HTML that doesn’t contain any custom tags (but may contain variables, e.g. @person.first_name).
A Tag section is HTML inside a custom tag (e.g. inside a
We do not parse every HTML tag inside the document for performance and memory usage reasons.