chore(export): rename html::Escape to HtmlEscape
This commit is contained in:
parent
fffadac04d
commit
8e3f3b333e
|
@ -17,9 +17,9 @@ use crate::export::write_datetime;
|
||||||
/// "<script>alert('Hello XSS')</script>"
|
/// "<script>alert('Hello XSS')</script>"
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Escape<S: AsRef<str>>(pub S);
|
pub struct HtmlEscape<S: AsRef<str>>(pub S);
|
||||||
|
|
||||||
impl<S: AsRef<str>> fmt::Display for Escape<S> {
|
impl<S: AsRef<str>> fmt::Display for HtmlEscape<S> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ pub trait HtmlHandler<E: From<Error>>: Default {
|
||||||
ExampleBlock(block) => write!(
|
ExampleBlock(block) => write!(
|
||||||
w,
|
w,
|
||||||
"<pre class=\"example\">{}</pre>",
|
"<pre class=\"example\">{}</pre>",
|
||||||
Escape(&block.contents)
|
HtmlEscape(&block.contents)
|
||||||
)?,
|
)?,
|
||||||
ExportBlock(block) => {
|
ExportBlock(block) => {
|
||||||
if block.data.eq_ignore_ascii_case("HTML") {
|
if block.data.eq_ignore_ascii_case("HTML") {
|
||||||
|
@ -93,14 +93,14 @@ pub trait HtmlHandler<E: From<Error>>: Default {
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<pre class=\"example\">{}</pre>",
|
"<pre class=\"example\">{}</pre>",
|
||||||
Escape(&block.contents)
|
HtmlEscape(&block.contents)
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"<div class=\"org-src-container\"><pre class=\"src src-{}\">{}</pre></div>",
|
"<div class=\"org-src-container\"><pre class=\"src src-{}\">{}</pre></div>",
|
||||||
block.language,
|
block.language,
|
||||||
Escape(&block.contents)
|
HtmlEscape(&block.contents)
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,16 +109,16 @@ pub trait HtmlHandler<E: From<Error>>: Default {
|
||||||
w,
|
w,
|
||||||
"<code class=\"src src-{}\">{}</code>",
|
"<code class=\"src src-{}\">{}</code>",
|
||||||
inline_src.lang,
|
inline_src.lang,
|
||||||
Escape(&inline_src.body)
|
HtmlEscape(&inline_src.body)
|
||||||
)?,
|
)?,
|
||||||
Code { value } => write!(w, "<code>{}</code>", Escape(value))?,
|
Code { value } => write!(w, "<code>{}</code>", HtmlEscape(value))?,
|
||||||
FnRef(_fn_ref) => (),
|
FnRef(_fn_ref) => (),
|
||||||
InlineCall(_) => (),
|
InlineCall(_) => (),
|
||||||
Link(link) => write!(
|
Link(link) => write!(
|
||||||
w,
|
w,
|
||||||
"<a href=\"{}\">{}</a>",
|
"<a href=\"{}\">{}</a>",
|
||||||
Escape(&link.path),
|
HtmlEscape(&link.path),
|
||||||
Escape(link.desc.as_ref().unwrap_or(&link.path)),
|
HtmlEscape(link.desc.as_ref().unwrap_or(&link.path)),
|
||||||
)?,
|
)?,
|
||||||
Macros(_macros) => (),
|
Macros(_macros) => (),
|
||||||
RadioTarget => (),
|
RadioTarget => (),
|
||||||
|
@ -128,7 +128,7 @@ pub trait HtmlHandler<E: From<Error>>: Default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Target(_target) => (),
|
Target(_target) => (),
|
||||||
Text { value } => write!(w, "{}", Escape(value))?,
|
Text { value } => write!(w, "{}", HtmlEscape(value))?,
|
||||||
Timestamp(timestamp) => {
|
Timestamp(timestamp) => {
|
||||||
use crate::elements::Timestamp;
|
use crate::elements::Timestamp;
|
||||||
|
|
||||||
|
@ -152,16 +152,20 @@ pub trait HtmlHandler<E: From<Error>>: Default {
|
||||||
write_datetime(&mut w, "[", start, "]–")?;
|
write_datetime(&mut w, "[", start, "]–")?;
|
||||||
write_datetime(&mut w, "[", end, "]")?;
|
write_datetime(&mut w, "[", end, "]")?;
|
||||||
}
|
}
|
||||||
Timestamp::Diary { value } => write!(&mut w, "<%%({})>", Escape(value))?,
|
Timestamp::Diary { value } => {
|
||||||
|
write!(&mut w, "<%%({})>", HtmlEscape(value))?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(&mut w, "</span></span>")?;
|
write!(&mut w, "</span></span>")?;
|
||||||
}
|
}
|
||||||
Verbatim { value } => write!(&mut w, "<code>{}</code>", Escape(value))?,
|
Verbatim { value } => write!(&mut w, "<code>{}</code>", HtmlEscape(value))?,
|
||||||
FnDef(_fn_def) => (),
|
FnDef(_fn_def) => (),
|
||||||
Clock(_clock) => (),
|
Clock(_clock) => (),
|
||||||
Comment { .. } => (),
|
Comment { .. } => (),
|
||||||
FixedWidth { value } => write!(w, "<pre class=\"example\">{}</pre>", Escape(value))?,
|
FixedWidth { value } => {
|
||||||
|
write!(w, "<pre class=\"example\">{}</pre>", HtmlEscape(value))?
|
||||||
|
}
|
||||||
Keyword(_keyword) => (),
|
Keyword(_keyword) => (),
|
||||||
Drawer(_drawer) => (),
|
Drawer(_drawer) => (),
|
||||||
Rule => write!(w, "<hr>")?,
|
Rule => write!(w, "<hr>")?,
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
mod html;
|
mod html;
|
||||||
mod org;
|
mod org;
|
||||||
|
|
||||||
pub use html::{DefaultHtmlHandler, Escape as HtmlEscape, HtmlHandler};
|
|
||||||
#[cfg(feature = "syntect")]
|
#[cfg(feature = "syntect")]
|
||||||
pub use html::SyntectHtmlHandler;
|
pub use html::SyntectHtmlHandler;
|
||||||
|
pub use html::{DefaultHtmlHandler, HtmlEscape, HtmlHandler};
|
||||||
pub use org::{DefaultOrgHandler, OrgHandler};
|
pub use org::{DefaultOrgHandler, OrgHandler};
|
||||||
|
|
||||||
use std::io::{Error, Write};
|
use std::io::{Error, Write};
|
||||||
|
|
Loading…
Reference in a new issue