using System.Linq; namespace Proostenkrant.NET { internal static class ArticleGenerator { internal static string GenerateArticle(string[][] rows) { var text = string.Empty; foreach (var row in rows) { var writers = row[1].Split(',').Select(w => w.Trim()).ToArray(); var title = row[2]; var date = row[3]; var mainText = row[4]; var imageName = row[5]; text += GenerateHeader(writers[0], title, date); text += GenerateBody(writers, date, mainText, imageName); text += "\n\n"; } return text; } static string GenerateHeader(string writer, string title, string date) { var text = string.Empty; text += "\\headline{" + title + "}\r\n"; text += "\\byline{" + date + "}{" + writer + "}\r\n"; return text; } static string GenerateBody(string[] writers, string date, string mainText, string imageName) { var text = string.Empty; if (writers.Length == 2) text += "\\showTwoWriters{Images/ProfilePictures/" + writers[0] + ".jpg}{" + writers[0] + "}{Images/ProfilePictures/" + writers[1] + ".jpg}{" + writers[1] + "}\r\n"; else text += "\\showOneWriter{Images/ProfilePictures/" + writers[0] + ".jpg}{" + writers[0] + "}\r\n"; text += "\\par " + mainText + "\r\n"; text += "\\showInlineImage{Images/Articles/" + imageName + ".jpg}{}\r\n"; return text; } } }