示例#1
0
        private void ParseParams(EMMarkdownTaggedElementMatch contentMatch, TransformationData data)
        {
            foreach (Match paramMatch in ParamPattern.Matches(contentMatch.Content))
            {
                var isLiteral = paramMatch.Groups["tagName"].Value.ToLower() == "paramliteral";
                var paramName = paramMatch.Groups["paramName"].Value;

                if (isLiteral)
                {
                    var text = new Regex("^" + Regex.Escape(paramMatch.Groups["indentation"].Value), RegexOptions.Multiline).Replace(paramMatch.Groups["content"].Value, "");

                    text = text.Trim('\n');

                    text = Markdown.OutdentIfPossible(text);
                    if (literalParams.ContainsKey(paramName))
                    {
                        literalParams[paramName].Add(text);
                    }
                    else
                    {
                        List <string> literalStrings = new List <string>();
                        literalStrings.Add(text);
                        literalParams.Add(paramName, literalStrings);
                    }
                }
                else
                {
                    var origin   = new EMElementOrigin(paramMatch.Groups["contentWithTags"].Index + contentMatch.ContentStart, paramMatch.Groups["contentWithTags"].Value);
                    var tagMatch = new EMMarkdownTaggedElementMatch(origin.Start, origin.Text, paramName,
                                                                    paramMatch.Groups["content"].Index - paramMatch.Groups["contentWithTags"].Index, paramMatch.Groups["content"].Length, paramName);

                    var param = EMObjectParam.CreateParam(origin, Document, this, data,
                                                          tagMatch, paramName, paramMatch.Groups["indentation"].Value);

                    if (literalParams.ContainsKey(paramName))
                    {
                        markdownParams[paramName].Add(param);
                    }
                    else
                    {
                        List <EMObjectParam> paramList = new List <EMObjectParam>();
                        paramList.Add(param);
                        markdownParams.Add(paramName, paramList);
                    }
                }
            }
        }
        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;
        }
示例#3
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);
        }