Skip to content

Commit

Permalink
Fix release action
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Oct 11, 2024
1 parent 2f2a016 commit 23307da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Test
name: Release

on:
push:
branches: [main]
pull_request:
branches: [main]
tags:
- v*

env:
CARGO_TERM_COLOR: always
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub struct MatterhornDocument<'d> {
pub content: &'d str,
}

/// Parse a full document into a front matter object and text content,
/// with auto-detection for the front matter type.
pub fn parse_document<'d>(
original_content: &'d str,
) -> Result<MatterhornDocument<'d>, MatterhornError> {
Expand Down Expand Up @@ -92,14 +94,20 @@ pub fn parse_document<'d>(
})
}

/// Parse JSON.
/// NB: Maintains source order.
pub fn parse_json(content: &str) -> Result<serde_json::Value, String> {
serde_json::from_str(content).map_err(|err| err.to_string())
}

/// Parse TOML.
pub fn parse_toml(content: &str) -> Result<serde_json::Value, String> {
toml::from_str(content).map_err(|err| err.to_string())
}

/// Parse YAML.
/// NB: Maintains source order.
/// NB: Allows duplicate keys.
pub fn parse_yaml(content: &str) -> Result<serde_json::Value, String> {
let mut yaml = saphyr::YamlLoader::load_from_str(content).map_err(|err| err.to_string())?;
yaml.retain(|val| !val.is_null());
Expand Down

0 comments on commit 23307da

Please sign in to comment.