Beispiel #1
0
        private void AddFrontMatterPropertyArg(string[] args, ref int i, Dictionary <string, PropertyMatchExpression> arg)
        {
            var argIndex = i;
            var argValue = GetArgParameter(args, ref i);

            if (argValue != null)
            {
                var pair = argValue.Split(":");

                if (pair.Length == 2)
                {
                    arg[pair[0]] = new PropertyMatchExpression(pair[1]);
                }
                else if (pair.Length == 3)
                {
                    if (Enum.TryParse <PropertyDataType>(pair[2], out var dataType))
                    {
                        arg[pair[0]] = new PropertyMatchExpression(pair[1], dataType);
                    }
                    else
                    {
                        this.Error = "Malformed argument value for " + args[argIndex] + " - unsupported data type " + pair[2];
                    }
                }
                else
                {
                    this.Error = "Malformed argument value for " + args[argIndex];
                }
            }
        }
Beispiel #2
0
        private static string?ExtractValue(PropertyMatchExpression matchExpression, HtmlDocument document, Uri pageUri)
        {
            var    xpathOrMacro = matchExpression.XpathOrMacro;
            string?text         = null;

            if (xpathOrMacro.StartsWith("{{"))
            {
                if (Regex.IsMatch(xpathOrMacro, @"^{{'[^']*'}}$"))
                {
                    text = xpathOrMacro[3..^ 3];