Thomas 1 ano atrás
pai
commit
e5fc451cf2
4 arquivos alterados com 61 adições e 63 exclusões
  1. 2 2
      src/lib.rs
  2. 20 20
      src/report.rs
  3. 0 4
      typst_template/min_template.typ
  4. 39 37
      typst_template/template.typ

+ 2 - 2
src/lib.rs

@@ -1,6 +1,6 @@
 pub mod cytoband;
-pub mod theme;
 pub mod report;
+pub mod theme;
 
 #[cfg(test)]
 mod tests {
@@ -10,7 +10,7 @@ mod tests {
         generate_chromosome_svg, read_ranges, svg_chromosome, AdditionalRect, Lollipop,
         RectPosition,
     };
-    use report::{compile_typst_report, write_report};
+    use report::compile_typst_report;
 
     use super::*;
 

+ 20 - 20
src/report.rs

@@ -4,26 +4,26 @@ use typst::foundations::{Bytes, Dict, Smart};
 use typst::text::Font;
 use typst_as_lib::TypstTemplate;
 
-pub fn write_report(path: &str) {
-    let font = include_bytes!("../typst_template/fonts/unicode.futurab.ttf");
-    let font = Font::new(Bytes::from_static(font), 0).expect("Could not parse font!");
-
-    let template = include_str!("../typst_template/min_template.typ");
-
-    let template = TypstTemplate::new(vec![font], template)
-        // .with_static_source_file_resolver(vec!["/"])
-        .with_package_file_resolver(Default::default(), None);
-
-    let mut tracer = Default::default();
-
-    let doc = template
-        .compile_with_input(&mut tracer, Dict::new())
-        .expect("typst::compile() returned an error!");
-
-    // Create pdf
-    let pdf = typst_pdf::pdf(&doc, Smart::Auto, None);
-    std::fs::write(path, pdf).expect("Could not write pdf.");
-}
+// pub fn write_report(path: &str) {
+//     let font = include_bytes!("../typst_template/fonts/unicode.futurab.ttf");
+//     let font = Font::new(Bytes::from_static(font), 0).expect("Could not parse font!");
+//
+//     let template = include_str!("../typst_template/min_template.typ");
+//
+//     let template = TypstTemplate::new(vec![font], template)
+//         // .with_static_source_file_resolver(vec!["/"])
+//         .with_package_file_resolver(Default::default(), None);
+//
+//     let mut tracer = Default::default();
+//
+//     let doc = template
+//         .compile_with_input(&mut tracer, Dict::new())
+//         .expect("typst::compile() returned an error!");
+//
+//     // Create pdf
+//     let pdf = typst_pdf::pdf(&doc, Smart::Auto, None);
+//     std::fs::write(path, pdf).expect("Could not write pdf.");
+// }
 
 pub fn compile_typst_report(id: &str) -> Result<(), std::io::Error> {
     let output = Command::new("typst")

+ 0 - 4
typst_template/min_template.typ

@@ -1,4 +0,0 @@
-#import "@preview/oxifmt:0.2.0"
-#import "@preview/cetz:0.2.2"
-// #import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge
-// #import "@preview/codelst:2.0.1": sourcecode

+ 39 - 37
typst_template/template.typ

@@ -13,15 +13,16 @@
 #import "@preview/metro:0.3.0": *
 #import "@preview/cetz:0.2.2"
 #import "@preview/badgery:0.1.1": *
+#import "@preview/cmarker:0.1.1"
 
 #set page(paper: "a4",
-  // fill: cr_colors.light_grey,
   footer: locate(loc => [
     #set text(10pt)
     #if loc.page() != 1 {
       align(right, counter(page).display("1 / 1", both: true))
     }
 ]))
+
 #show heading: set text(font: "Futura")
 #show heading.where(level: 1): it => [
   #set align(center)
@@ -432,45 +433,45 @@
   }
 }
 
-// #let add_newlines(text, n) = {
-//   let result = ""
-//   let chars = text.clusters()
-//   for (i, char) in chars.enumerate() {
-//     result += char
-//     if calc.rem((i + 1), n == 0 and i < chars.len() - 1 {
-//       result += "\n"
+// // #let add_newlines(text, n) = {
+// //   let result = ""
+// //   let chars = text.clusters()
+// //   for (i, char) in chars.enumerate() {
+// //     result += char
+// //     if calc.rem((i + 1), n == 0 and i < chars.len() - 1 {
+// //       result += "\n"
+// //     }
+// //   }
+// //   result
+// // }
+//
+// #let break_long_words(text, max_length: 20, hyphen: "") = {
+//   let words = text.split(" ")
+//   let result = ()
+//
+//   for word in words {
+//     if word.len() <= max_length {
+//       result.push(word)
+//     } else {
+//       let segments = ()
+//       let current_segment = ""
+//       for char in word.clusters() {
+//         if current_segment.len() + 1 > max_length {
+//           segments.push(current_segment + hyphen)
+//           current_segment = ""
+//         }
+//         current_segment += char
+//       }
+//       if current_segment != "" {
+//         segments.push(current_segment)
+//       }
+//       result += segments
 //     }
 //   }
-//   result
+//
+//   result.join(" ")
 // }
-
-#let break_long_words(text, max_length: 20, hyphen: "") = {
-  let words = text.split(" ")
-  let result = ()
-
-  for word in words {
-    if word.len() <= max_length {
-      result.push(word)
-    } else {
-      let segments = ()
-      let current_segment = ""
-      for char in word.clusters() {
-        if current_segment.len() + 1 > max_length {
-          segments.push(current_segment + hyphen)
-          current_segment = ""
-        }
-        current_segment += char
-      }
-      if current_segment != "" {
-        segments.push(current_segment)
-      }
-      result += segments
-    }
-  }
-
-  result.join(" ")
-}
-
+//
 #let format_sequence(text, max_length: 40, hyphen: [#linebreak()]) = {
   let words = text.split(" ")
   let result = ()
@@ -831,3 +832,4 @@
 #pagebreak()
 == Conclusion
 
+#cmarker.render(read(sys.inputs.base + "/diag/report/" + sys.inputs.id + "_conclusion.md"))