예제 #1
0
        protected bool ParseCodeOptions(
            BlockProcessor state,
            ref StringSlice line,
            IFencedBlock fenced,
            char openingCharacter)
        {
            if (!(fenced is AnnotatedCodeBlock annotatedBlock))
            {
                return(false);
            }

            var result = _codeFenceAnnotationsParser.TryParseCodeFenceOptions(
                line.ToString(),
                state.Context);

            switch (result)
            {
            case FailedCodeFenceOptionParseResult failed:
                foreach (var errorMessage in failed.ErrorMessages)
                {
                    annotatedBlock.Diagnostics.Add(errorMessage);
                }

                return(true);

            case SuccessfulCodeFenceOptionParseResult codeResult:
                annotatedBlock.Annotations = codeResult.Annotations;
                return(true);
            }

            return(false);
        }
예제 #2
0
        protected bool ParseCodeOptions(
            BlockProcessor state,
            ref StringSlice line,
            IFencedBlock fenced)
        {
            if (!(fenced is AnnotatedCodeBlock codeLinkBlock))
            {
                return(false);
            }

            var result = codeFenceAnnotationsParser.TryParseCodeFenceOptions(line.ToString(),
                                                                             state.Context);

            switch (result)
            {
            case NoCodeFenceOptions _:
                return(false);

            case FailedCodeFenceOptionParseResult failed:
                foreach (var errorMessage in failed.ErrorMessages)
                {
                    codeLinkBlock.Diagnostics.Add(errorMessage);
                }

                break;

            case SuccessfulCodeFenceOptionParseResult successful:
                codeLinkBlock.Annotations = successful.Annotations;
                break;
            }

            return(true);
        }
예제 #3
0
        private bool PlantUmlInfoParser(BlockProcessor state, ref StringSlice line, IFencedBlock fenced, char openingCharacter)
        {
            string infoString;
            string argString = null;

            var c = line.CurrentChar;
            // An info string cannot contain any backsticks
            int firstSpace = -1;

            for (int i = line.Start; i <= line.End; i++)
            {
                c = line.Text[i];
                if (c == '`')
                {
                    return(false);
                }

                if (firstSpace < 0 && c.IsSpaceOrTab())
                {
                    firstSpace = i;
                }
            }

            if (firstSpace > 0)
            {
                infoString = line.Text.Substring(line.Start, firstSpace - line.Start).Trim();

                // Skip any spaces after info string
                firstSpace++;
                while (true)
                {
                    c = line[firstSpace];
                    if (c.IsSpaceOrTab())
                    {
                        firstSpace++;
                    }
                    else
                    {
                        break;
                    }
                }

                argString = line.Text.Substring(firstSpace, line.End - firstSpace + 1).Trim();
            }
            else
            {
                infoString = line.ToString().Trim();
            }

            if (infoString != "plantuml")
            {
                return(false);
            }

            fenced.Info      = HtmlHelper.Unescape(infoString);
            fenced.Arguments = HtmlHelper.Unescape(argString);

            return(true);
        }
예제 #4
0
 private static bool NoInfoParser(BlockProcessor state, ref StringSlice line, IFencedBlock fenced, char openingCharacter)
 {
     for (int i = line.Start; i <= line.End; i++)
     {
         if (!line.Text[i].IsSpaceOrTab())
         {
             return(false);
         }
     }
     return(true);
 }
예제 #5
0
        private static bool NoInfoParser(BlockProcessor state, ref StringSlice line, IFencedBlock fenced)
        {
            char c;

            for (int i = line.Start; i <= line.End; i++)
            {
                c = line.Text[i];
                if (!c.IsSpaceOrTab())
                {
                    return(false);
                }
            }
            return(true);
        }