pub struct BeginWhile { /* private fields */ }Expand description
A region that opens at a begin match and continues, line by line, for
as long as a while pattern matches at the start of each following line
("begin"/"while"), as Markdown block quotes and lists do.
Numbered back-references in while stand for the text begin groups
captured.
§Examples
use textmate_lang::{BeginWhile, Grammar, Rule};
let quote = BeginWhile::new(r"^\s*(>) ?", r"^\s*(>) ?")
.scope("markup.quote.demo")
.begin_capture(1, "punctuation.definition.quote.demo")
.while_capture(1, "punctuation.definition.quote.demo")
.pattern(Rule::include_self());
let json = Grammar::new("text.demo").pattern(quote).to_json()?;
assert!(json.contains(r#""while": "^\\s*(>) ?""#));Implementations§
Source§impl BeginWhile
impl BeginWhile
Sourcepub fn new(
begin: impl Into<Cow<'static, str>>,
while_: impl Into<Cow<'static, str>>,
) -> BeginWhile
pub fn new( begin: impl Into<Cow<'static, str>>, while_: impl Into<Cow<'static, str>>, ) -> BeginWhile
A region opened by begin and continued while while_ matches.
| Parameter | Meaning |
|---|---|
begin | The pattern that opens the region. |
while_ | The pattern each following line must start with; \n back-references name begin groups. |
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^(\\s{4})", "^\\1").scope("markup.raw.block.demo"))
.to_json()?;
assert!(json.contains(r#""while": "^\\1""#));Sourcepub fn scope(self, scope: impl Into<Cow<'static, str>>) -> BeginWhile
pub fn scope(self, scope: impl Into<Cow<'static, str>>) -> BeginWhile
Scopes the whole region ("name"). $n substitutions name begin
groups.
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^>", "^>").scope("markup.quote.demo"))
.to_json()?;
assert!(json.contains("markup.quote.demo"));Sourcepub fn content_scope(self, scope: impl Into<Cow<'static, str>>) -> BeginWhile
pub fn content_scope(self, scope: impl Into<Cow<'static, str>>) -> BeginWhile
Scopes the region without the begin match ("contentName").
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^>", "^>").content_scope("markup.quote.content.demo"))
.to_json()?;
assert!(json.contains(r#""contentName": "markup.quote.content.demo""#));Sourcepub fn capture(self, group: u32, capture: impl Into<Capture>) -> BeginWhile
pub fn capture(self, group: u32, capture: impl Into<Capture>) -> BeginWhile
Sets capture group for both begin and while ("captures").
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^(>)", "^(>)").capture(1, "punctuation.demo"))
.to_json()?;
assert!(json.contains(r#""captures": {"#));Sourcepub fn begin_capture(
self,
group: u32,
capture: impl Into<Capture>,
) -> BeginWhile
pub fn begin_capture( self, group: u32, capture: impl Into<Capture>, ) -> BeginWhile
Sets capture group of begin ("beginCaptures").
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^(>)", "^>").begin_capture(1, "punctuation.demo"))
.to_json()?;
assert!(json.contains(r#""beginCaptures": {"#));Sourcepub fn while_capture(
self,
group: u32,
capture: impl Into<Capture>,
) -> BeginWhile
pub fn while_capture( self, group: u32, capture: impl Into<Capture>, ) -> BeginWhile
Sets capture group of while ("whileCaptures").
§Examples
use textmate_lang::{BeginWhile, Grammar};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^>", "^(>)").while_capture(1, "punctuation.demo"))
.to_json()?;
assert!(json.contains(r#""whileCaptures": {"#));Sourcepub fn pattern(self, rule: impl Into<Rule>) -> BeginWhile
pub fn pattern(self, rule: impl Into<Rule>) -> BeginWhile
Adds a rule that applies inside the region ("patterns").
§Examples
use textmate_lang::{BeginWhile, Grammar, Match};
let json = Grammar::new("text.demo")
.pattern(BeginWhile::new("^>", "^>").pattern(Match::new(r"\*\*").scope("markup.bold.demo")))
.to_json()?;
assert!(json.contains("markup.bold.demo"));Trait Implementations§
Source§impl Clone for BeginWhile
impl Clone for BeginWhile
Source§impl Debug for BeginWhile
impl Debug for BeginWhile
impl Eq for BeginWhile
Source§impl From<BeginWhile> for Rule
impl From<BeginWhile> for Rule
Source§fn from(rule: BeginWhile) -> Rule
fn from(rule: BeginWhile) -> Rule
Converts to this type from the input type.
Source§impl PartialEq for BeginWhile
impl PartialEq for BeginWhile
impl StructuralPartialEq for BeginWhile
Auto Trait Implementations§
impl Freeze for BeginWhile
impl RefUnwindSafe for BeginWhile
impl Send for BeginWhile
impl Sync for BeginWhile
impl Unpin for BeginWhile
impl UnsafeUnpin for BeginWhile
impl UnwindSafe for BeginWhile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more