Compare commits

..

2 Commits

Author SHA1 Message Date
403620396b Added documentation for paragraph 2026-03-02 23:48:44 +01:00
d6052a624e Formatted code 2026-03-02 23:48:30 +01:00
2 changed files with 20 additions and 1 deletions

View File

@@ -77,6 +77,21 @@ impl Parse for BaseElement {
} }
} }
/// # HTML Paragraph element
/// # Usage:
/// ```rust
/// use web_macro::paragraph;
/// let single_line = paragraph!("This is my lovely text to be displayed", id="title", class="small blue");
/// let multi_line = paragraph!(
/// "This is my lovely text to be displayed",
/// "This is another line that constitutes my paragraph",
/// id="title",
/// class="small blue"
/// );
/// ```
/// # Notes:
/// - This element supports child insertions, see usage.
/// - Adding multiple children will **not** insert _\<br\>_
#[proc_macro] #[proc_macro]
pub fn paragraph(input: TokenStream) -> TokenStream { pub fn paragraph(input: TokenStream) -> TokenStream {
base("p", input) base("p", input)

View File

@@ -19,7 +19,11 @@ mod tests {
fn test_multiple_elements_with_options() { fn test_multiple_elements_with_options() {
assert_eq!( assert_eq!(
"<div id=\"division_id\">\n<h1>one</h1>\n<h1 class=\"tiny\">two</h1>\n</div>", "<div id=\"division_id\">\n<h1>one</h1>\n<h1 class=\"tiny\">two</h1>\n</div>",
division!(heading1!("one"), heading1!("two", class="tiny"), id="division_id") division!(
heading1!("one"),
heading1!("two", class = "tiny"),
id = "division_id"
)
) )
} }
} }