diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | dec7cf62faf74695e78940ba5a4073dc8cfc3552 (patch) | |
tree | b6c61bbe05cd6a119185fa4fb9773560888005bb | |
parent | cd520f255da770afb061ecc731f61bc3c27d7ab5 (diff) | |
download | skaldpress-dec7cf62faf74695e78940ba5a4073dc8cfc3552.tar.gz skaldpress-dec7cf62faf74695e78940ba5a4073dc8cfc3552.zip |
Allow inline html in markdown
-rw-r--r-- | src/skaldpress/error.rs | 4 | ||||
-rw-r--r-- | src/skaldpress/main.rs | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/skaldpress/error.rs b/src/skaldpress/error.rs index 83b5253..fb47ff0 100644 --- a/src/skaldpress/error.rs +++ b/src/skaldpress/error.rs @@ -17,6 +17,7 @@ pub enum SkaldpressError { DirectoryCreateError(u8, std::io::Error, String), MetadataError(u8, std::io::Error), SMPError(u8, SMPError), + MarkdownError(u8), } impl fmt::Display for SkaldpressError { @@ -43,6 +44,9 @@ impl fmt::Display for SkaldpressError { SkaldpressError::SMPError(code, e) => { write!(f, "[SP{}] Macro processing error \"{:#?}\"", code, e) } + SkaldpressError::MarkdownError(code) => { + write!(f, "[SP{}] Error parsing markdown into HTML", code) + } } } } diff --git a/src/skaldpress/main.rs b/src/skaldpress/main.rs index 25a3e92..9c9332c 100644 --- a/src/skaldpress/main.rs +++ b/src/skaldpress/main.rs @@ -207,7 +207,18 @@ fn compile_file(file_path: &Path, opts: &Opts) -> Result<CompiledFile, Skaldpres SP_COMPILE_FILE_EXTENSION_ERROR_2, None, ))? { - "md" => markdown::to_html(file_content), + "md" => markdown::to_html_with_options( + file_content, + &markdown::Options { + parse: markdown::ParseOptions::gfm(), + compile: markdown::CompileOptions { + allow_dangerous_html: true, + allow_dangerous_protocol: true, + ..markdown::CompileOptions::default() + }, + }, + ) + .map_err(|_e| SkaldpressError::MarkdownError(15))?, _ => file_content.to_string(), }; |