-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support toml values with equal sign
- Loading branch information
1 parent
f278374
commit ffb819c
Showing
10 changed files
with
378 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
- [Overview](./overview.md) | ||
- [Reference](./reference.md) | ||
- [Examples](./examples.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Examples | ||
|
||
## Combining multiple custom properties | ||
|
||
Note that the comma `,` is used to seperate custom options. | ||
|
||
```` | ||
```admonish quote collapsible=true, title='A title that really <span style="color: #e70073">pops</span>' | ||
To really <b><span style="color: #e70073">grab</span></b> your reader's attention. | ||
``` | ||
```` | ||
|
||
```admonish quote collapsible=true, title='A title that really <span style="color: #e70073">pops</span>' | ||
To really <b><span style="color: #e70073">grab</span></b> your reader's attention. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use once_cell::sync::Lazy; | ||
use regex::Regex; | ||
use serde::Deserialize; | ||
use std::fmt::Display; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] | ||
pub(crate) struct UserInput { | ||
#[serde(default)] | ||
pub r#type: Option<String>, | ||
#[serde(default)] | ||
pub title: Option<String>, | ||
#[serde(default)] | ||
pub id: Option<String>, | ||
#[serde(default)] | ||
pub class: Option<String>, | ||
#[serde(default)] | ||
pub collapsible: Option<bool>, | ||
} | ||
|
||
impl UserInput { | ||
pub fn classnames(&self) -> Vec<String> { | ||
self.class | ||
.as_ref() | ||
.map(|class| { | ||
class | ||
.split(' ') | ||
.filter(|classname| !classname.is_empty()) | ||
.map(|classname| classname.to_owned()) | ||
.collect() | ||
}) | ||
.unwrap_or_default() | ||
} | ||
} | ||
|
||
pub(crate) static RX_DIRECTIVE: Lazy<Regex> = | ||
Lazy::new(|| Regex::new(r#"^[A-Za-z0-9_-]+$"#).expect("directive regex")); | ||
|
||
pub(crate) fn format_toml_parsing_error(error: impl Display) -> String { | ||
format!("TOML parsing error: {error}") | ||
} | ||
|
||
pub(crate) fn format_invalid_directive(directive: &str, original_error: impl Display) -> String { | ||
format!("'{directive}' is not a valid directive or TOML key-value pair.\n\n{original_error}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.