-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support toml values with equal sign #181
Merged
+378
−53
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tommilligan, seems like this line now causes quite some prints during the build that are not really relevant. Very minor issue, but maybe that was not intended ?
Looks like this:
.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-admonish-1.17.0/src/config/v2.rs:63:58] config_toml = "collapsible=true \ntitle=\"Display value (without control)\""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes this was indeed unintentional. Opened #186 to resolve