Exemple #1
0
        public static YamlBlock ExtractBlock(string s)
        {
            var match      = YamlRegEx.MatchFull(s);
            var scalarType = DetectScalarType(match);

            switch (scalarType)
            {
            case ScalarType.FlowDoubleQuoted:
                return(new YamlBlock(match.IndentLength, match.Suffix, UnescapeDoubleQuotedString(match.Content)));

            case ScalarType.FlowSingleQuoted:
                return(new YamlBlock(match.IndentLength, match.Suffix, UnescapeSingleQuotedString(match.Content)));

            case ScalarType.BlockFolded:
            case ScalarType.BlockFoldedKeep:
            case ScalarType.BlockFoldedStrip:
            case ScalarType.BlockLiteral:
            case ScalarType.BlockLiteralKeep:
            case ScalarType.BlockLiteralStrip:
                return(new YamlBlock(match.IndentLength, match.Suffix, UnescapeBlock(match.Content, scalarType)));

            case ScalarType.Plain:
                return(new YamlBlock(match.IndentLength, match.Suffix, match.Content));

            default:
                return(null);
            }
        }
Exemple #2
0
 public static ScalarType DetectScalarType(string line)
 => DetectScalarType(YamlRegEx.Match(line));