".to_string())?;
- PS.with(|ps_cell| {
- let ps = ps_cell.borrow();
- if let Some(syntax) = ps.find_syntax_by_token(self.language.as_str()) {
- TS.with(|ts_cell| {
- let ts = ts_cell.borrow();
-
- let _ = writer.write(highlighted_html_for_string(
- self.code.as_str(),
- &ps,
- syntax,
- &ts.themes["InspiredGitHub"],
- ));
- })
- } else {
- let _ = writer.write("".to_string());
- let _ = writer.write(self.code.clone());
- let _ = writer.write("
".to_string());
- }
- })
+ lazy_static::lazy_static! { static ref PS: SyntaxSet = SyntaxSet::load_defaults_nonewlines(); }
+ lazy_static::lazy_static! { static ref TS: ThemeSet = ThemeSet::load_defaults(); }
+
+ if let Some(syntax) = PS.find_syntax_by_token(self.language.as_str()) {
+ writer.write(highlighted_html_for_string(
+ self.code.as_str(),
+ &PS,
+ syntax,
+ &TS.themes["InspiredGitHub"],
+ ))?;
+ } else {
+ writer.write("".to_string())?;
+ writer.write_escaped(self.code.clone())?;
+ writer.write("
".to_string())?;
+ }
} else {
writer.write(">".to_string())?;
writer.write_escaped(self.code.clone())?;
@@ -334,13 +327,13 @@ impl ToHtml for CodeBlock {
impl ToHtml for Quote {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("".to_string())?;
for line in &self.text {
line.to_html(writer)?;
- writer.write("
".to_string())?;
+ writer.write("
".to_string())?;
}
if let Some(meta) = self.metadata.clone() {
- writer.write("".to_string())?;
+ writer.write("".to_string())?;
meta.to_html(writer)?;
writer.write("".to_string())?;
}
@@ -350,7 +343,7 @@ impl ToHtml for Quote {
impl ToHtml for Ruler {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("
".to_string())
+ writer.write("
".to_string())
}
}
@@ -387,26 +380,26 @@ impl ToHtml for Image {
}
}
if let Some(description) = self.url.description.clone() {
- writer.write("".to_string())?;
} else {
- writer.write("".to_string())?;
+ writer.write("\"/>".to_string())?;
}
Ok(())
@@ -465,7 +458,7 @@ impl ToHtml for SuperscriptText {
impl ToHtml for MonospaceText {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("".to_string())?;
writer.write_escaped(self.value.clone())?;
writer.write("
".to_string())
@@ -474,9 +467,9 @@ impl ToHtml for MonospaceText {
impl ToHtml for Url {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("\">".to_string())?;
if let Some(description) = self.description.clone() {
for desc in description {
desc.to_html(writer)?;
@@ -500,18 +493,18 @@ impl ToHtml for Placeholder {
if let Some(value) = &self.value {
value.to_html(writer)
} else {
- writer.write("Unknown placeholder '".to_string())?;
+ writer.write("".to_string())
}
}
}
impl ToHtml for RefLink {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("\">".to_string())?;
self.description.to_html(writer)?;
writer.write("".to_string())
@@ -538,7 +531,7 @@ impl ToHtml for InlineMetadata {
impl ToHtml for Centered {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("
".to_string())?;
self.line.to_html(writer)?;
writer.write("
".to_string())
@@ -547,7 +540,7 @@ impl ToHtml for Centered {
impl ToHtml for Checkbox {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("
io::Result<()> {
- writer.write("
".to_string())?;
+ writer.write("\">".to_string())?;
writer.write(self.value.to_string())?;
writer.write("".to_string())
@@ -569,9 +562,9 @@ impl ToHtml for Emoji {
impl ToHtml for Colored {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("
".to_string())?;
+ writer.write("".to_string())?;
self.value.to_html(writer)?;
writer.write("".to_string())
@@ -580,9 +573,9 @@ impl ToHtml for Colored {
impl ToHtml for BibReference {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("".to_string())?;
writer.write(self.get_formatted())?;
writer.write("".to_string())
@@ -622,9 +615,9 @@ impl ToHtml for CharacterCode {
impl ToHtml for Anchor {
fn to_html(&self, writer: &mut HTMLWriter) -> io::Result<()> {
- writer.write("".to_string())?;
+ writer.write("\">".to_string())?;
self.inner.to_html(writer)?;
writer.write("
".to_string())
diff --git a/src/main.rs b/src/main.rs
index 0d600ec..d145f31 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -88,15 +88,18 @@ fn render(opt: &Opt) -> Parser {
);
let start_render = Instant::now();
let file = OpenOptions::new()
- .write(true)
.read(true)
+ .write(true)
+ .truncate(true)
+ .create(true)
.open(&opt.output)
.unwrap();
let writer = BufWriter::new(file);
match opt.format.as_str() {
"html" => {
let mut writer = HTMLWriter::new(Box::new(writer));
- document.to_html(&mut writer).unwrap()
+ document.to_html(&mut writer).unwrap();
+ writer.flush().unwrap();
}
_ => println!("Unknown format {}", opt.format),
}
diff --git a/src/references/configuration/mod.rs b/src/references/configuration/mod.rs
index d7dfa1f..6e2ac9c 100644
--- a/src/references/configuration/mod.rs
+++ b/src/references/configuration/mod.rs
@@ -56,7 +56,7 @@ impl ConfigEntry {
impl Default for Configuration {
fn default() -> Self {
let mut self_config = Self::new();
- self_config.set(BIB_REF_DISPLAY, Value::String("number".to_string()));
+ self_config.set(BIB_REF_DISPLAY, Value::String("{{number}}".to_string()));
self_config.set(META_LANG, Value::String("en".to_string()));
self_config