MarkdownDeep.StringScanner.SkipIdentifier C# (CSharp) Method

SkipIdentifier() public method

public SkipIdentifier ( string &identifier ) : bool
identifier string
return bool
        public bool SkipIdentifier(ref string identifier)
        {
            int savepos = position;
            if (!Utils.ParseIdentifier(this.str, ref pos, ref identifier))
                return false;
            if (pos >= end)
            {
                pos = savepos;
                return false;
            }
            return true;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Skips the font awesome specification at the current specified pos. Pos is inside str at the '@'. font awesome
        /// directives are @fa-iconname. newPos is positioned to character after iconname if successful match. iconname scanned is specified in iconname.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <param name="currentPos">The current position.</param>
        /// <param name="newPos">The new position.</param>
        /// <param name="iconName">Name of the icon.</param>
        /// <returns>
        /// bool if match was found and properly skipped, otherwise false.
        /// </returns>
        public static bool SkipFontAwesome(string str, int currentPos, out int newPos, out string iconName)
        {
            newPos   = currentPos;
            iconName = string.Empty;
            if (str[currentPos] != '@')
            {
                return(false);
            }

            var scanner = new StringScanner(str, currentPos);

            // skip '@'
            scanner.SkipForward(1);
            if (!scanner.DoesMatch("fa-"))
            {
                // not a font awesome specification
                return(false);
            }
            scanner.SkipForward(3);
            iconName = string.Empty;
            if (!scanner.SkipIdentifier(ref iconName))
            {
                // no icon name specified
                return(false);
            }
            if (string.IsNullOrWhiteSpace(iconName))
            {
                return(false);
            }
            // matched a fontawesome specification
            newPos = scanner.Position;
            return(true);
        }
All Usage Examples Of MarkdownDeep.StringScanner::SkipIdentifier