(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
SetDirectory["C:\\drorbn\\AcademicPensieve\\Talks/Sydney-191002"];
Get["../../Talks/Matemale-1804/CellExport.m"];
BeginPackage["Snips`", {"CellExport`"}];
MakeSnips;
Begin["`private`"];
SetOptions[$FrontEndSession,PrintingStyleEnvironment->"Working"];


(* ::Input::Initialization:: *)
WinSort[names_List]:=names[[Ordering[Characters[names]]]];


(* ::Input::Initialization:: *)
MakeSnips[nb_] := (
If[FileType["Snips/"<>nb]===None, CreateDirectory["Snips/"<>nb]];
If[FileType["Snips/"<>nb<>"/Verification.txt"]===None\[Or]AbsoluteTime@FileDate["Snips/"<>nb<>"/Verification.txt"]<AbsoluteTime@FileDate[nb<>".nb"],
If[Head[$FrontEnd]===FrontEndObject,
SetOptions[CellExport, ExportFormat -> ".pdf", Split -> True, PageWidth -> 7.12, ExportOptions -> {ImageSize->Scaled[0.75]}],
SetOptions[CellExport, ExportFormat -> ".pdf", Split -> True, PageWidth -> 7.12]
];
SourceNotebook =NotebookGet@NotebookOpen[Directory[]<>"/"<>nb<>".nb"];
DialogTags={};
tags=Cases[SourceNotebook, (CellTags->tag_) :> tag, Infinity ] // Union;
files=Reap[Flatten[Table[
Which[
tag=="817", { (* this is only left here as a demo for how to make an exception *)
Sow@CellExport[SourceNotebook, "817", {CellFilter -> First, ExportBaseFilename -> "Snips/"<>nb<>"/817-In"}],
Sow@CellExport[SourceNotebook, "817", {CellFilter -> Rest, ExportBaseFilename -> "Snips/"<>nb<>"/817-Out", PageWidth -> 5.5*0.24/0.16}]
},
MemberQ[DialogTags, tag], {
Sow@CellExport[SourceNotebook, tag, {CellFilter -> First, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag<>"-In"}],
Sow@CellExport[SourceNotebook, tag, {CellFilter -> Rest, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag<>"-Out"}]
},
True, Sow@CellExport[SourceNotebook, tag, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag]
],
{tag, tags}]]];
PutAppend[DateString[], "Snips/"<>nb<>"/Verification.txt"];
files=Flatten[files];
DeleteFile /@ Complement[StringReplace["\\"->"/"]/@FileNames["Snips/"<>nb<>"/*.pdf"], files];
WinSort@Union[files],
(*Else*)
WinSort@FileNames["Snips/"<>nb<>"/*.pdf"]
]
)


(* ::Input::Initialization:: *)
End[]; EndPackage[];
