Esempio n. 1
0
 public EMCodeBlock(EMDocument doc, EMElementOrigin origin, EMElement parent, string rawText, bool singleLine = false)
     : base(doc, origin, parent)
 {
     this.rawText    = rawText;
     this.singleLine = singleLine;
 }
Esempio n. 2
0
        private static EMElement CreateFromInline(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var alt            = match.Groups[2].Value;
            var url            = match.Groups[3].Value;
            var title          = match.Groups[6].Value;
            var width          = match.Groups[9].Value;
            var height         = match.Groups[11].Value;
            var align          = match.Groups[13].Value;
            var convert        = match.Groups[15].Value;
            var convertType    = match.Groups[17].Value;
            var convertQuality = match.Groups[19].Value;
            var hexFillColor   = match.Groups[21].Value;

            return(Create(
                       data, doc, origin, parent, url, alt, title, convert, width,
                       height, convertQuality, hexFillColor, convertType,
                       new ImageOptions(width, height, align)));
        }
Esempio n. 3
0
 private EMRelativeLink(EMDocument doc, EMElementOrigin origin, EMElement parent, EMPathProvider path)
     : base(doc, origin, parent)
 {
     this.path = path;
 }
Esempio n. 4
0
 public EMFormattedText(EMDocument doc, EMElementOrigin origin, EMElement parent)
     : base(doc, origin, parent)
 {
 }
        private static EMElement Create(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var bookmark = match.Groups["BookmarkName"].Value;

            return(new EMBookmark(doc, origin, parent, bookmark));
        }
Esempio n. 6
0
        private static List <TableRowInformation> GetHeaders(EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data, int headerOffset, string tableHeader, out bool useRowHeader)
        {
            // Add headers
            // May be multiple lines, may have columns spanning
            // May also have no header if we are intending the 1st column to be the header

            var map = new PreprocessedTextLocationMap();

            tableHeader = RemoveTrailingWhitespaceAndNewLines(tableHeader, map);

            List <TableRowInformation> templateHeaderRows = null;

            useRowHeader = true;

            if (!String.IsNullOrWhiteSpace(tableHeader))
            {
                templateHeaderRows = new List <TableRowInformation>();

                var headerRowOffset = 0;

                var headerRows = Regex.Split(tableHeader, @"\n");
                foreach (var headerRow in headerRows)
                {
                    var count = 0;

                    var headerColumns = Regex.Matches(headerRow, @"[ ]?([^\|]+)[ ]?([\|]*)");
                    var row           = new TableRowInformation();

                    foreach (Match headerColumn in headerColumns)
                    {
                        var cellGroup        = headerColumn.Groups[1];
                        var columnSpanLength = 1;

                        if (Regex.Match(headerColumn.Groups[2].Value, @"(\|{2,})").Success)
                        {
                            columnSpanLength = Regex.Match(headerColumn.Groups[2].Value, @"(\|{2,})").Length;
                        }

                        var cell = new TableCellInformation(doc, new EMElementOrigin(headerOffset + map.GetOriginalPosition(headerRowOffset + cellGroup.Index, PositionRounding.Down), cellGroup.Value), parent, data, columnSpanLength, null, true);

                        if (count == 0)
                        {
                            useRowHeader = !Regex.Match(cell.ToString(), @"(\S)").Success;
                        }

                        count++;

                        row.Cells.Add(cell);
                    }

                    headerRowOffset += headerRow.Length + 1;
                    templateHeaderRows.Add(row);
                }
            }

            return(templateHeaderRows);
        }
 private EMHorizontalRule(EMDocument doc, EMElementOrigin origin, EMElement parent)
     : base(doc, origin, parent)
 {
 }
        private static EMElement Create(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var bqTextGroup = match.Groups[1];
            var bqText      = bqTextGroup.Value;

            bqText = Regex.Replace(bqText, @"^[ ]*>[ ]?", "", RegexOptions.Multiline);       // trim one level of quoting
            bqText = Regex.Replace(bqText, @"^[ ]+$", "", RegexOptions.Multiline);           // trim whitespace-only lines

            var bq = new EMBlockQuotes(doc, origin, parent);

            bq.Elements.Parse(origin.Start + bqTextGroup.Index, bqText, data);

            return(bq);
        }
Esempio n. 9
0
 public EMRegion(EMDocument doc, EMElementOrigin origin, EMElement parent, EMMarkdownTaggedElementMatch match, string regionParam, bool singleLine = false)
     : base(doc, origin, parent, match.ContentStart, match.ContentLength)
 {
     this.singleLine = singleLine;
     RegionParam     = regionParam;
 }
 protected EMElementWithElements(EMDocument doc, EMElementOrigin origin, EMElement parent, int elementsOriginOffset, int elementsOriginLength)
     : base(doc, origin, parent)
 {
     Elements = new EMElements(doc, new EMElementOrigin(elementsOriginOffset, origin.Text.Substring(elementsOriginOffset, elementsOriginLength)), this);
 }
 private EMBlockQuotes(EMDocument doc, EMElementOrigin origin, EMElement parent)
     : base(doc, origin, parent, 0, origin.Length)
 {
 }
Esempio n. 12
0
        private static EMHeader CreateFromSetextMatch(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var headerText = match.Groups[2].Value;
            var level      = match.Groups[3].Value.StartsWith("=") ? 1 : 2;
            var isOptional = string.IsNullOrWhiteSpace(match.Groups[1].Value);

            headerText = Markdown.Unescape(data.Markdown.RunSpanGamut(headerText, data));

            return(new EMHeader(doc, origin, parent, level, headerText, isOptional));
        }
Esempio n. 13
0
        private static EMHeader CreateFromAtxMatch(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var headerText = match.Groups[3].Value;

            if (headerText.Contains("ifndef") || headerText.Contains("endif"))
            {
                return(null);
            }

            var level      = match.Groups[1].Value.Length;
            var isOptional = string.IsNullOrWhiteSpace(match.Groups[2].Value);

            headerText = Markdown.Unescape(data.Markdown.RunSpanGamut(headerText, data));

            return(new EMHeader(doc, origin, parent, level, headerText, isOptional));
        }
Esempio n. 14
0
 public EMElement Create(IMatch match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
 {
     return(new EMCodeBlock(doc, origin, parent, (match as EMCodeBlockParserMatch).Content));
 }
 public EMDecorationElement(EMDocument doc, EMElementOrigin origin, EMElement parent, EMDecorationType type)
     : base(doc, origin, parent)
 {
     this.type = type;
     Content   = new EMSpanElements(doc, new EMElementOrigin(0, origin.Text), this);
 }
Esempio n. 16
0
 public EMObjectParam(EMDocument doc, EMElementOrigin origin, EMElement parent, EMMarkdownTaggedElementMatch match, string paramName)
     : base(doc, origin, parent, match.ContentStart, match.ContentLength)
 {
     ParamName = paramName;
 }
Esempio n. 17
0
        private static List <TableRowInformation> GetRows(
            EMElement parent,
            TransformationData data,
            int tableDataOffset,
            string tableData,
            string[] alignments,
            bool useRowHeader,
            bool hasHeader)
        {
            // Add body data
            var tableRows = new List <TableRowInformation>();

            var map = new PreprocessedTextLocationMap();

            tableData = RemoveTrailingWhitespaceAndNewLines(tableData, map);

            var dataRows = Regex.Split(tableData, @"\n");

            var rowOffset = 0;

            for (var i = 0; i < dataRows.Count(); ++i)
            {
                var dataRow = dataRows[i];

                // Parse table into List of List of CellInformation
                var count = 0;

                var dataColumns = Regex.Matches(dataRow, @"([^\|]+)([\|]*)");

                var tableRow = new TableRowInformation();

                // Check to see if someone has left an empty row incorrectly formatted, which we can fix.
                if (dataColumns.Count == 0)
                {
                    var fixedDataRow = dataRow;
                    for (var j = dataRow.Length; j < alignments.Length + 1; ++j)
                    {
                        fixedDataRow += '|';
                    }
                    fixedDataRow = fixedDataRow.Insert(1, " ");

                    dataColumns = Regex.Matches(fixedDataRow, @"([^\|]+)([\|]*)");
                }

                foreach (Match dataColumn in dataColumns)
                {
                    int addToOffset;
                    var cell = Normalizer.LeadingWhitespaceRemove(dataColumn.Groups[1].Value, out addToOffset);
                    cell = Normalizer.TrailingWhitespaceRemove(cell);

                    var columnSpanLength = 1;
                    var isRowHeader      = (count == 0 && useRowHeader && dataColumns.Count > 1) ||
                                           (dataColumns.Count == 1 && i == 0 && !hasHeader);

                    if (Regex.Match(dataColumn.Groups[2].Value, @"(\|{2,})").Success)
                    {
                        columnSpanLength = Regex.Match(dataColumn.Groups[2].Value, @"(\|{2,})").Length;
                    }

                    // @UE3 ensure that the index into alignments is not greater than the amount expected. (Users may accidentally add extra || to lines)
                    string alignment = null;
                    if (count >= alignments.Length)
                    {
                        // Report only 1 error per row per run to avoid duplicates
                        if (!tableRow.HasError)
                        {
                            var errorCount = data.ErrorList.Count;
                            tableRow.ErrorId  = errorCount;
                            tableRow.HasError = true;
                            data.ErrorList.Add(
                                Markdown.GenerateError(
                                    Language.Message(
                                        "MoreColumnsThanAllignmentsInOneOfTheTableRowsColumnsIgnored",
                                        Markdown.Unescape(dataRows[i])),
                                    MessageClass.Error,
                                    Markdown.Unescape(dataRows[i]),
                                    errorCount,
                                    data));
                        }
                    }
                    else
                    {
                        alignment = alignments[count];
                    }

                    var cellInformation = (cell.Trim() != "^")
                                              ? new TableCellInformation(
                        parent.Document,
                        new EMElementOrigin(tableDataOffset + map.GetOriginalPosition(addToOffset + rowOffset + dataColumn.Groups[1].Index, PositionRounding.Down), cell),
                        parent, data, columnSpanLength, alignment, isRowHeader)
                                              : new TableCellInformation(columnSpanLength, alignment, isRowHeader, false, 1, true);

                    tableRow.Cells.Add(cellInformation);

                    // Make parsing table easier later, if ColumnSpan > 1 create a blank column for each over one
                    for (var dummyColumnCount = 1; dummyColumnCount < columnSpanLength; ++dummyColumnCount)
                    {
                        tableRow.Cells.Add(new TableCellInformation(0));
                    }

                    // @UE3 this was not in original specification, handles correct alignment of a subsequent column after a long column.
                    count += columnSpanLength;
                }
                // If count is zero check that someone has just not placed a space in the first column indicating it should be empty.

                if (count < alignments.Length)
                {
                    var errorCount = data.ErrorList.Count;
                    tableRow.ErrorId  = errorCount;
                    tableRow.HasError = true;
                    data.ErrorList.Add(
                        Markdown.GenerateError(
                            Language.Message(
                                "LessColumnsThanExpectedInOneOfTheTableRowsEmptyCellsInserted", Markdown.Unescape(dataRows[i])),
                            MessageClass.Error,
                            Markdown.Unescape(dataRows[i]),
                            errorCount,
                            data));
                }

                // If count is less than total expected for a rows data add dummy column and raise error
                for (var dummyColumnCount = count; dummyColumnCount < alignments.Length; ++dummyColumnCount)
                {
                    tableRow.Cells.Add(new TableCellInformation(1, null, false, true));
                }

                tableRows.Add(tableRow);

                rowOffset += dataRow.Length + 1;
            }

            // Now work out rowspans based on Content and character ^
            // Work down rows in columns

            for (var columnNumber = 0; columnNumber < alignments.Length; ++columnNumber)
            {
                var firstNonSpanRow = -1;
                for (var rowNumber = 0; rowNumber < tableRows.Count; ++rowNumber)
                {
                    if (tableRows[rowNumber].Cells[columnNumber].IsRowSpanColumn) //Found a rowspan column
                    {
                        if (rowNumber == 0)
                        {
                            var errorCount = data.ErrorList.Count;
                            tableRows[rowNumber].ErrorId  = errorCount;
                            tableRows[rowNumber].HasError = true;
                            data.ErrorList.Add(
                                Markdown.GenerateError(
                                    Language.Message(
                                        "ColumnCannotBeSetToSpanWithSpecialSymbolInTheFirstRowOfATable", dataRows[0]),
                                    MessageClass.Error,
                                    dataRows[0],
                                    errorCount,
                                    data));
                        }
                        else
                        {
                            if (firstNonSpanRow < 0)
                            {
                                //is this the first detected row for this span?
                                firstNonSpanRow = rowNumber - 1;

                                //Row span above this 1 now should include itself
                                tableRows[firstNonSpanRow].Cells[columnNumber].RowSpanCount = 1;
                            }

                            //Increment the Row above first_row detected by 1
                            tableRows[firstNonSpanRow].Cells[columnNumber].RowSpanCount += 1;
                        }
                    }
                    else if (firstNonSpanRow >= 0)
                    {
                        //This row is not a rowspan but we had one previously so clear for any other rowspans in the column
                        firstNonSpanRow = -1;
                    }
                }
            }

            return(tableRows);
        }
Esempio n. 18
0
        public static EMObjectParam CreateParam(EMElementOrigin origin, EMDocument doc, EMElement parent, TransformationData data, EMMarkdownTaggedElementMatch match, string paramName, string paramIndentation)
        {
            var content = new EMObjectParam(doc, origin, parent, match, paramName);

            var text =
                Preprocessor.Replace(
                    new Regex(
                        "^" + Regex.Escape(paramIndentation), RegexOptions.Multiline),
                    content.Elements.Origin.Text,
                    "",
                    content.Elements.TextMap);

            text = Preprocessor.Trim(text, '\n', content.Elements.TextMap);

            text = Markdown.OutdentIfPossible(text, content.Elements.TextMap);

            content.Elements.Parse(0, text, data);

            return(content);
        }
Esempio n. 19
0
 private static EMElement CreateTable(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
 {
     return(new EMTable(doc, origin, parent, match, data));
 }
Esempio n. 20
0
        public static EMElement CreateIncludeFilesFromText(string text, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var specs = Preprocessor.UnescapeChars(IncludeFilesPattern.Match(text).Groups["specs"].Value, true);

            var paths = GetIncludesFromPathSpecs(specs, data);

            var inclusions = new EMElements(doc, origin, parent);

            var i = 0;

            foreach (var path in paths)
            {
                var pathOrigin = new EMElementOrigin(i, "");

                try
                {
                    bool languageChanged;

                    var excerpt =
                        ExcerptsManager.Get(data.ProcessedDocumentCache,
                                            Path.Combine(data.CurrentFolderDetails.AbsoluteMarkdownPath, path),
                                            data.CurrentFolderDetails.Language,
                                            "",
                                            out languageChanged);

                    inclusions.Add(new EMInclude(doc, pathOrigin, inclusions, excerpt, 0, languageChanged, false));
                }
                catch (ExcerptsManagerException e)
                {
                    inclusions.Add(EMErrorElement.Create(doc, pathOrigin, inclusions, data, e.MessageId, e.MessageArgs));
                }

                ++i;
            }

            return(inclusions);
        }
Esempio n. 21
0
 private static EMElement Create(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
 {
     return(new EMHorizontalRule(doc, origin, parent));
 }
Esempio n. 22
0
 public static EMElement CreateFromText(
     string text, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
 {
     return(Create(IncludePattern.Match(text), doc, origin, parent, data));
 }
 protected EMBookmark(EMDocument doc, EMElementOrigin origin, EMElement parent, string bookmark)
     : base(doc, origin, parent)
 {
     Name      = bookmark;
     UniqueKey = MakeUniqueKey(Name.ToLower());
 }
Esempio n. 24
0
        private static EMElement Create(
            Match match,
            EMDocument doc,
            EMElementOrigin origin,
            EMElement parent,
            TransformationData data)
        {
            var includeFileFolderName = "";
            var includeRegion         = "";

            var thisOffset = 0;

            if (match.Groups["includeFileRegion"].Value.Contains('#'))
            {
                includeFileFolderName = match.Groups["includeFileRegion"].Value.Split('#')[0];
                includeRegion         = match.Groups["includeFileRegion"].Value.Split('#')[1];

                if (!includeRegion.StartsWith("doxygen"))
                {
                    includeRegion = includeRegion.ToLower();
                }
            }
            else
            {
                includeFileFolderName = match.Groups["includeFileRegion"].Value;
            }

            if (includeFileFolderName.ToUpper().Contains("%ROOT%"))
            {
                includeFileFolderName = ".";
            }

            if (String.IsNullOrWhiteSpace(includeFileFolderName))
            {
                if (String.IsNullOrWhiteSpace(includeRegion))
                {
                    // Error cannot have no region and no file specified.
                    return(EMErrorElement.Create(
                               data.Document,
                               origin,
                               parent,
                               data,
                               "ExcerptRegionToIncludeWhenNoFileGiven"));
                }

                // Assume that this is a reference to a location in this file.
                includeFileFolderName = doc.GetAbsoluteMarkdownPath();
            }

            if (!String.IsNullOrWhiteSpace(match.Groups["offsetValue"].Value) &&
                !int.TryParse(match.Groups["offsetValue"].Value, out thisOffset))
            {
                return(EMErrorElement.Create(
                           data.Document,
                           origin,
                           parent,
                           data,
                           "ValueMustBeNumber"));
            }

            try
            {
                bool languageChanged;

                var excerpt =
                    ExcerptsManager.Get(data.ProcessedDocumentCache,
                                        Path.Combine(data.CurrentFolderDetails.AbsoluteMarkdownPath, includeFileFolderName),
                                        data.CurrentFolderDetails.Language,
                                        includeRegion,
                                        out languageChanged);

                return(new EMInclude(doc, origin, parent, excerpt, thisOffset, languageChanged));
            }
            catch (ExcerptsManagerException e)
            {
                return(EMErrorElement.Create(doc, origin, parent, data, e.MessageId, e.MessageArgs));
            }
        }
Esempio n. 25
0
        private static EMElement CreateFromReference(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var alt = match.Groups[2].Value;


            var linkId = match.Groups[3].Value.ToLowerInvariant();

            // for shortcut links like ![this][].
            if (linkId == "")
            {
                linkId = alt.ToLowerInvariant();
            }

            alt = alt.Replace("\"", "&quot;");

            if (!data.ReferenceLinks.Urls.ContainsKey(linkId))
            {
                return(EMErrorElement.Create(doc, origin, parent, data, "MissingImageRef", linkId));
            }

            var url = data.ReferenceLinks.Urls[linkId];

            var imageFormat = data.ReferenceLinks.ReferenceAttributes[linkId];

            var width          = imageFormat.Width;
            var height         = imageFormat.Height;
            var convert        = imageFormat.DoCompressImages;
            var convertType    = imageFormat.ConvertImageFormat;
            var convertQuality = imageFormat.ImageQuality;
            var hexFillColor   = imageFormat.ImageFill;

            var options = data.ReferenceLinks.ImageAlignment.ContainsKey(linkId)
                              ? data.ReferenceLinks.ImageAlignment[linkId]
                              : new ImageOptions();

            var title = data.ReferenceLinks.Titles.ContainsKey(linkId)
                            ? Markdown.EscapeBoldItalic(data.ReferenceLinks.Titles[linkId])
                            : null;

            return(Create(
                       data, doc, origin, parent, url, alt, title, convert, width,
                       height, convertQuality, hexFillColor, convertType, options));
        }
Esempio n. 26
0
 private EMParagraph(EMDocument doc, EMElementOrigin origin, EMElement parent, EMSpanElements content)
     : base(doc, origin, parent)
 {
     this.content = content;
 }
Esempio n. 27
0
        private static EMElement Create(
            TransformationData data,
            EMDocument doc,
            EMElementOrigin origin,
            EMElement parent,
            string url,
            string alt,
            string title,
            string convert,
            string width,
            string height,
            string convertQuality,
            string hexFillColor,
            string convertType,
            ImageOptions options)
        {
            ImageFormat imageFormatType;

            if (String.IsNullOrWhiteSpace(url))
            {
                return(EMErrorElement.Create(doc, origin, parent, data, "EmptyLink", origin.Text));
            }

            alt = alt.Replace("\"", "&quot;");

            if (title != null)
            {
                title = title.Replace("\"", "&quot;");
            }

            if (url.StartsWith("<") && url.EndsWith(">"))
            {
                url = url.Substring(1, url.Length - 2); // Remove <>'s surrounding URL, if present
            }

            if (String.IsNullOrWhiteSpace(alt))
            {
                //if no alt text provided use the file name.
                alt = Regex.Replace(url, @".*[\\|/](.*)", "$1");
            }

            var doConvert = !convert.ToLower().Equals("false") && data.Markdown.DefaultImageDoCompress;

            int widthIntConverted;
            int heightIntConverted;
            int quality;

            Color fillColor;

            if (doConvert)
            {
                //if we are converting try to get the other values
                //try parse the strings for width and height into integers
                try
                {
                    widthIntConverted = Int32.Parse(width);
                }
                catch (FormatException)
                {
                    widthIntConverted = 0;
                }

                try
                {
                    heightIntConverted = Int32.Parse(height);
                }
                catch (FormatException)
                {
                    heightIntConverted = 0;
                }

                try
                {
                    quality = Int32.Parse(convertQuality);
                }
                catch (FormatException)
                {
                    quality = data.Markdown.DefaultImageQuality;
                }

                try
                {
                    fillColor = ImageConversion.GetColorFromHexString(hexFillColor);
                }
                catch (Exception)
                {
                    fillColor = data.Markdown.DefaultImageFillColor;
                }

                if (String.IsNullOrWhiteSpace(convertType))
                {
                    convertType     = data.Markdown.DefaultImageFormatExtension;
                    imageFormatType = data.Markdown.DefaultImageFormat;
                }
                else
                {
                    try
                    {
                        imageFormatType = ImageConversion.GetImageFormat(convertType.ToLower());
                    }
                    catch (Exception)
                    {
                        return(EMErrorElement.Create(
                                   doc,
                                   origin,
                                   parent,
                                   data,
                                   "UnsupportedImageFileTypeConversion",
                                   Markdown.Unescape(url),
                                   convertType.ToLower()));
                    }
                }
            }
            else
            {
                //set width and height to zero indicating to converter that we want to use the images values
                widthIntConverted  = 0;
                heightIntConverted = 0;

                //set conversion type to itself, but do check it is a supported image type.
                convertType =
                    Regex.Match(Markdown.Unescape(url), @"\.(png|gif|tga|bmp|jpg)", RegexOptions.IgnoreCase).Groups[1].Value;

                try
                {
                    imageFormatType = ImageConversion.GetImageFormat(convertType.ToLower());
                }
                catch (Exception)
                {
                    return(EMErrorElement.Create(
                               doc,
                               origin,
                               parent,
                               data,
                               "UnsupportedImageFileTypeConversion",
                               Markdown.Unescape(url),
                               convertType.ToLower()));
                }

                quality   = 100;
                fillColor = data.Markdown.DefaultImageFillColor;
            }

            if (!String.IsNullOrWhiteSpace(convertType))
            {
                try
                {
                    var path = new EMLocalFilePath(Markdown.Unescape(url), doc, data,
                                                   fileName => System.IO.Path.GetFileNameWithoutExtension(fileName) + "." + ImageConversion.GetImageExt(imageFormatType));

                    if (!path.IsImage)
                    {
                        throw new EMPathVerificationException(Language.Message("GivenPathIsNotAnImage", url));
                    }

                    data.ImageDetails.Add(
                        new ImageConversion(
                            path.GetSource(),
                            path.GetAbsolutePath(data),
                            widthIntConverted,
                            heightIntConverted,
                            doConvert,
                            imageFormatType,
                            fillColor,
                            quality));

                    return(new EMImage(doc, origin, parent, path, title, alt, options));
                }
                catch (EMPathVerificationException e)
                {
                    return(new EMErrorElement(doc, origin, parent, e.AddToErrorList(data, origin.Text)));
                }
            }

            throw new InvalidOperationException("Should not happen!");
        }
Esempio n. 28
0
        private static EMElement CreateParagraph(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
        {
            var contentGroup = match.Groups["content"];
            var spanContent  = new EMSpanElements(doc, new EMElementOrigin(origin.Start, contentGroup.Value), parent);

            spanContent.Parse(contentGroup.Value, data);

            return(new EMParagraph(doc, origin, parent, spanContent));
        }
Esempio n. 29
0
        public static EMElement CreateFromText(string text, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data, bool imageLink = false)
        {
            try
            {
                var path = EMPathProvider.CreatePath(text, doc, data);

                return(new EMRelativeLink(doc, origin, parent, path));
            }
            catch (EMPathVerificationException e)
            {
                return(new EMErrorElement(doc, origin, parent, e.AddToErrorList(data, origin.Text)));
            }
        }
Esempio n. 30
0
 private static EMElement CreateCodeBlock(EMCodeBlockParserMatch match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data)
 {
     return(new EMCodeBlock(doc, origin, parent, match.Content));
 }