private string Encode(string str) { str = Latex.EncodeLatex(str); str = Latex.ReplaceURL(str); str = _emojis.ReplaceEmojis(str); return(str); }
private void ToLaTex_Click(object sender, RoutedEventArgs e) { Cursor = Cursors.Wait; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "LaTex Files (*.tex)|*.tex"; saveFileDialog.InitialDirectory = ReadConf("LatexFolder"); if (saveFileDialog.ShowDialog() != true) { return; } try { Latex latex = new Latex(saveFileDialog.FileName, _LyliPath); latex.BuildRow(); latex.BuildLaTex(); _log.Debug("Create and Compile latex file: " + saveFileDialog.FileName); MessageBox.Show("Votre tablature à bien été créée dans le dossier: " + ReadConf("TabFolder") + @"\", "Tablature", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception exeption) { MessageBox.Show(exeption.Message.ToString(), "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); _log.Error("Error Latex: " + exeption.Message); } Cursor = Cursors.Arrow; }
public async Task <IActionResult> MdToPdf() { try { using (var reader = new System.IO.StreamReader(Request.Body)) using (var writer = new System.IO.StringWriter()) { Markdig.Markdown.Parse(await reader.ReadToEndAsync()).ToLatex(writer); return(File(await Latex.Compile(writer.ToString(), null), "application/pdf")); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private void AppendMediaMessage(MediaMessage msg, StringBuilder sb) { var str = string.Format(@"{0} \textit{{{1}}}", FormatSenderAndTime(msg), Latex.EncodeLatex(msg.Filename)); if (!string.IsNullOrWhiteSpace(msg.Subscription)) { str = str + " - " + Encode(msg.Subscription); } sb.AppendLine(str); sb.AppendLine(@"\\"); }
public async Task <IActionResult> Compile([FromRoute] Guid?id) { try { Template template = null; if (id.HasValue) { template = Database.Templates.First(t => t.ID == id); } using (var reader = new System.IO.StreamReader(Request.Body)) { var mem = await Latex.Compile(await reader.ReadToEndAsync(), template); return(File(mem, "application/pdf")); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private static string GetDateString(DateTime date) { var dayName = "UNKNOWN"; switch (date.DayOfWeek) { case DayOfWeek.Monday: dayName = "Montag"; break; case DayOfWeek.Tuesday: dayName = "Dienstag"; break; case DayOfWeek.Wednesday: dayName = "Mittwoch"; break; case DayOfWeek.Thursday: dayName = "Donnerstag"; break; case DayOfWeek.Friday: dayName = "Freitag"; break; case DayOfWeek.Saturday: dayName = "Samstag"; break; case DayOfWeek.Sunday: dayName = "Sonntag"; break; } var monthName = Latex.EncodeLatex(_months[date.Month - 1]); return($"{dayName}, der {date.Day}. {monthName} {date.Year}"); }
public override void run() { LoggerInitialization.SetThreshold(typeof(SingleDistributionExperiment), LogLevel.Debug); SingletonLogger.Instance().DebugLog(typeof(SingleDistributionExperiment), "run()"); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "distribution => " + theActualDistribution); IAgentFactory af = CreateAgentFactory(theActualDistribution, theTableConfig.AgentFactoryClassName); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "agent factory => " + theTableConfig.AgentFactoryClassName); af.Initialize(theTableConfig); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "creating initial orderbook"); IOrderbook_Observable ob = new Orderbook(); /* No Burnin at this point * * SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Executing burnin..."); * IPopulation popburn = CreatePopulation(af, theTableConfig.NumAgents, Path.Combine(ApplicationConfig.ROOTDIR, theTableConfig.InitialOrderbook)); * ISimulation simburn = new Simulation(popburn, ob, 0.0, COMMON_BURNIN_TIME_SECONDS, false, "burnin") ; * ISimulationResults resultsburn = simburn.run(); * ob = (IOrderbook_Observable)simburn.Orderbook; * SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Done with burnin."); */ ISimulationBundle accumulated_simb = null; ISimulationResultsBundle accumulated_resb = null; for (int popi = 0; popi < theTableConfig.Populations; popi++) { SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "creating population... " + theTableConfig.NumAgents); // Populations all contain an OrderBookLoader agent IPopulation pop = CreatePopulation(af, theTableConfig.NumAgents, Path.Combine(ApplicationConfig.ROOTDIR, theTableConfig.InitialOrderbook)); // SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "done."); string popname = POP_FILE_PREFIX + "." + popi + ".Validation"; string poppath = Path.Combine(_popdir, popname); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "population " + popi + " => " + poppath); savePopulation(poppath, pop); _simb = new SimulationBundle(pop, ob, 0.0, theTableConfig.DurationHours * 3600.0, LOG_FRAMES, "pop-" + popi); if (accumulated_simb == null) { accumulated_simb = _simb; } foreach (TrajectoryFactoryConfig tfc in theTrajConfig.getTrajectories()) { IPassiveTrajectoryFactory tf = CreatePassiveTrajectoryFactory(tfc); tf.Initialize(theTableConfig); _simb.add(tf); } /* * foreach (IAgent ag in pop) { * if (ag is IAgent_NonParticipant) continue; * * _simb.add (new TrajectoryFactory_AgentNamedMetric(ag, Agent1x0.NetWorth_METRICNAME, 1.0, 0.0)); * } */ double MAX_ALPHA = 0.10; double TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES = 1.0; for (double alpha = 0.0; alpha <= MAX_ALPHA; alpha += MAX_ALPHA / (double)theTableConfig.NumCombs) { TrajectoryFactory_AlphaSlice tf = new TrajectoryFactory_AlphaSlice(TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES, 0.0, alpha, true); tf.Initialize(theTableConfig); _simb.add(tf); TrajectoryFactory_AlphaSlice tf2 = new TrajectoryFactory_AlphaSlice(TEMPORAL_GRANULARITY_FOR_ALPHA_SLICES, 0.0, alpha, false); tf2.Initialize(theTableConfig); _simb.add(tf2); } foreach (AgentEvaluationConfig aefc in theAgentEvaluationFactorySetConfig.getAgentEvaluations()) { IAgentEvaluationFactory aef = CreateAgentEvaluationFactory(aefc); _simb.add(aef, aefc); } _resb = _simb.run(theTableConfig.Trials); //popname = POP_FILE_PREFIX+"."+popi+".Validation-Post"; //poppath = Path.Combine(_popdir, popname); //SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "population post "+popi+" => "+poppath); //savePopulation(poppath, pop); if (accumulated_resb == null) { accumulated_resb = _resb; } else { accumulated_resb.add(_resb); } //WriteTrajectories(popi, _simb, _resb); } //WriteTrajectories(-1, accumulated_simb, accumulated_resb); PresentationConfig.Directory = Path.Combine(OutputDirectory, "results"); if (!Directory.Exists(PresentationConfig.Directory)) { Directory.CreateDirectory(PresentationConfig.Directory); } Latex.ClearImages(); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing BlauSpaceEvaluations."); foreach (IAgentEvaluationBundle aeb in accumulated_resb.getAgentEvaluationBundles()) { IBlauSpaceLattice bsl = accumulated_simb.getLattice(theActualDistribution, aeb); IBlauSpaceEvaluation meanEval = aeb.MeanEvaluation(bsl); IBlauSpaceEvaluation stdEval = aeb.StdEvaluation(bsl); BlauSpaceEvaluationGnuplotPresenter pres = new BlauSpaceEvaluationGnuplotPresenter(_bsedir, PresentationConfig.Directory); pres.Present(this, meanEval, stdEval); } SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing TrajectoryBundles."); foreach (ITrajectoryBundle tb in accumulated_resb.getTrajectoryBundles()) { TrajectoryBundleGnuplotPresenter pres = new TrajectoryBundleGnuplotPresenter(_trajdir, PresentationConfig.Directory); pres.Present(this, tb); } SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Writing Latex."); Latex.Instance().Present(this); CreateReport(this); SingletonLogger.Instance().InfoLog(typeof(SingleDistributionExperiment), "Done."); }
public void TestReplaceURL_Http_Words_Https() { Assert.AreEqual(@"\url{http://as.de} Some other word \url{https://bla.com}", Latex.ReplaceURL("http://as.de Some other word https://bla.com")); }
public void TestReplaceURL_Https_WordsPrefix() { Assert.AreEqual(@"Some words \url{https://bla.com}", Latex.ReplaceURL("Some words https://bla.com")); }
public void TestReplaceURL_None() { Assert.AreEqual("abcdef", Latex.ReplaceURL("abcdef")); }
public void TestReplaceURL_Https_LatexEscape() { Assert.AreEqual("\\url{https://bla.com/asd\\&a=1} abcdef", Latex.ReplaceURL("https://bla.com/asd\\&a=1 abcdef")); }
public void TestReplaceURL_Https_LatexNewline() { Assert.AreEqual("\\url{https://bla.com/asd}\\\\abcdef", Latex.ReplaceURL("https://bla.com/asd\\\\abcdef")); }
public void TestReplaceURL_Http_Sandwich() { Assert.AreEqual(@"aa \url{http://def} ijk", Latex.ReplaceURL("aa http://def ijk")); }
public void TestReplaceURL_Https_Only() { Assert.AreEqual(@"\url{https://ab.cd.ef/blub}", Latex.ReplaceURL("https://ab.cd.ef/blub")); }
public void TestReplaceURL_Http_Only() { Assert.AreEqual(@"\url{http://ab.cd.ef}", Latex.ReplaceURL("http://ab.cd.ef")); }
private static string FormatSenderAndTime(IMessage msg) { var sender = string.Format(@"\textbf{{{0}}}", Latex.EncodeLatex(msg.Sender)); return(string.Format("{0} ({1}):", sender, GetTimeString(msg.Timepoint))); }