Пример #1
0
 public static IEnumerable <IEnumerable <String> > ExtractFromSourceFileDefault(
     this LitOptions LO,
     MDSourceFile sourcefile
     )
 {
     return(ParsingTools.PartitionLines(
                sourcefile.Lines,
                line => System.Text.RegularExpressions.Regex.IsMatch(line, @"^#[^#]")
                ));
 }
Пример #2
0
        public static IEnumerable <IEnumerable <String> > ExtractSubElmsDefault(
            this LitOptions LO,
            IEnumerable <String> lines
            )
        {
            //Partition the events
            int headerLevel = LO.ParseHeader(lines.First()).HeaderLevel + 1;
            var pattern     = String.Format(@"^{0}[^#]", new String('#', headerLevel));

            return(ParsingTools.PartitionLines(lines, line => System.Text.RegularExpressions.Regex.IsMatch(line, pattern)));
        }
Пример #3
0
        public static LitRef ParseToLitRefDefault(this LitOptions LO, LitNovel novel, IEnumerable <String> lines)
        {
            if (lines.Count() == 0)
            {
                return(null);
            }
            var PartitionedLines = ParsingTools.PartitionLines(lines, l => System.Text.RegularExpressions.Regex.IsMatch(l, @"^##[^#]"));
            var link             = PartitionedLines.First().Select(s => LO.ParseLink(s)).Where(l => l != null).First();

            var retVal = new LitRef();

            //Do the specific things for this style of reference
            if (link.Link.Equals("Reference"))
            {
                if (link.Tag.Equals("Character"))
                {
                    retVal = new LitChar();
                    (retVal as LitChar).ParseLitChar(PartitionedLines);
                }
                else if (link.Tag.Equals("Place"))
                {
                    retVal = new LitPlace();
                }
                else if (link.Tag.Equals("Myth"))
                {
                    retVal = new LitMyth();
                }
                else if (link.Tag.Equals("Object"))
                {
                    retVal = new LitObject();
                }
            }

            //Get the first tag of the reference
            string pattern = @"^# (.+)";
            var    match   = System.Text.RegularExpressions.Regex.Match(lines.First(), pattern);

            retVal.Tags.Add(new LitTag(match.Groups[1].Value));

            //Save the commentary
            retVal.Commentary = LO.SourceLinesToString(PartitionedLines.First());

            //Save the tags
            pattern = "^## Tags$";
            var tagsList = PartitionedLines.Where(list => System.Text.RegularExpressions.Regex.IsMatch(list.First(), pattern)).First();

            foreach (var tagline in tagsList.Where(s => LO.IsSourceLine(s)))
            {
                retVal.AddTag(new LitTag(tagline));
            }

            return(novel.AddReferenceDistinct(retVal));
        }
Пример #4
0
        public static IEnumerable <IEnumerable <String> > ExtractNotesRefsDefault(
            this LitOptions LO,
            MDNotesFile notesfile
            )
        {
            string pattern = @"^#[^#]";

            return(ParsingTools.PartitionLines(
                       notesfile.Lines,
                       (s => System.Text.RegularExpressions.Regex.IsMatch(s, pattern))
                       ));
        }
Пример #5
0
        /// <summary>
        /// Default implentation to takes all of the source lines of a list of arbitrary strings and turns them into a string
        /// GOOD!
        /// </summary>
        public static String SourceLinesToStringDefault(this LitOptions LO, IEnumerable <string> lines)
        {
            var           paragraphs = ParsingTools.PartitionLines(lines.Where(s => LO.IsSourceLine(s)), line => String.IsNullOrWhiteSpace(line));
            StringBuilder sb         = new StringBuilder();

            foreach (var paralist in paragraphs)
            {
                foreach (var paraline in paralist.Where(l => !String.IsNullOrEmpty(l)))
                {
                    sb.Append(paraline.TrimEnd('\r', '\n'));
                    sb.Append(" ");
                }
                sb.Append("\r\n");
            }
            return(sb.ToString().Trim());
        }
Пример #6
0
        public static List <MDTag> GetAllTagsDefault(this LitOptions LO, LitElm elm, String Filename, int HeaderLevel)
        {
            var retVal   = new List <MDTag>();
            var tempList = new List <LitTag>();

            tempList.Add(elm.TreeTag);
            tempList.AddRange(elm.UserTags);
            retVal = tempList.Select(t => new MDTag()
            {
                TagName = t.Tag,
                TagFile = Filename,
                TagLine = LO.WriteElmTagEX(elm)
            }).ToList();

            foreach (var child in elm.Children)
            {
                retVal.AddRange(ParsingTools.GetAllTagsDefault(LO, child, Filename, HeaderLevel + 1));
            }
            return(retVal);
        }
Пример #7
0
 /// <summary>
 /// Takes a litelm and writes all of the lines for that elm that go into the source for a particular Author
 /// </summary>
 /// <param name="LO"></param>
 /// <param name="litElm"></param>
 /// <param name="author"></param>
 /// <returns></returns>
 public static List <String> WriteSourceLinesDefault(this LitOptions LO, LitElm litElm, LitAuthor author)
 {
     return(ParsingTools.WriteSourceLinesDefault(LO, litElm, author, 1));
 }
Пример #8
0
 public static List <MDTag> GetAllTagsDefault(this LitOptions LO, LitElm elm, String Filename)
 {
     return(ParsingTools.GetAllTagsDefault(LO, elm, Filename, 1));
 }
Пример #9
0
 public static String ToSourceLine(this LitAuthor sourceinfo)
 {
     return(ParsingTools.MakeLinkLine("Author", sourceinfo.Author));
 }