Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public static List <String> WriteNotesMythLinesDefault(
            this LitOptions LO,
            LitNovel novel,
            LitMyth myth
            )
        {
            var retVal  = new List <String>();
            var AllElms = novel.AllElms();

            //Show actor instances
            var eventHeader = new MDHeader()
            {
                HeaderLevel = 2,
                Text        = "Event of"
            };

            retVal.Add(eventHeader.ToString());
            retVal.AddRange(
                AllElms
                .Where(e => e.Events.Contains(myth))
                .Select(e => e.TreeTag.ToHyperlink())
                );

            //Show mentions
            var mythHeader = new MDHeader()
            {
                HeaderLevel = 2,
                Text        = "Mentioned in"
            };

            retVal.Add(mythHeader.ToString());
            retVal.AddRange(
                AllElms
                .Where(e => e.References.Contains(myth))
                .Select(e => e.TreeTag.ToHyperlink())
                );

            return(retVal);
        }