summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/skaldpress/error.rs4
-rw-r--r--src/skaldpress/main.rs13
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(),
};