Example #1
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);
        }
        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);
        }