예제 #1
0
        private IEnumerable <MarkdownSourceLineEntry> ProcessIgnoreDirective(MarkdownSourceLineEntry entry, string[] arguments)
        {
            if (arguments.Length != 1)
            {
                throw new ErrorMessageException(
                          String.Format(Properties.Resources.IgnoreDirectiveNeedsExactlyOneArgumentErrorMessage, arguments.Length,
                                        entry.FileName, entry.LineNumber, entry.Line));
            }

            string warningCode = arguments[0].ToUpper();

            switch (warningCode)
            {
            case "W001":
                _Configuration.IgnoreWarnings.Add(warningCode);
                break;

            default:
                throw new ErrorMessageException(
                          String.Format(Properties.Resources.IgnoreDirectiveUnknownWarningCodeErrorMessage,
                                        entry.FileName, entry.LineNumber, entry.Line));
            }

            yield break;
        }
예제 #2
0
        private IEnumerable <MarkdownSourceLineEntry> ProcessTitleDirective(MarkdownSourceLineEntry entry, string[] arguments)
        {
            if (arguments.Length != 1)
            {
                throw new ErrorMessageException(
                          String.Format(Properties.Resources.TitleDirectiveNeedsExactlyOneArgumentErrorMessage, arguments.Length,
                                        entry.FileName, entry.LineNumber, entry.Line));
            }

            if (_Configuration.Title != string.Empty)
            {
                if (!_Configuration.IgnoreWarnings.Contains("W001"))
                {
                    Console.Error.WriteLine(String.Format(Properties.Resources.MultipleTitlesSpecifiedWarningMessage, arguments[0]));
                }
            }
            _Configuration.Title = arguments[0];

            yield break;
        }
예제 #3
0
        private IEnumerable <MarkdownSourceLineEntry> ProcessDirective(MarkdownSourceLineEntry entry)
        {
            string directiveLine = entry.Line.Substring(3);

            if (directiveLine.TrimStart() != directiveLine)
            {
                throw new ErrorMessageException(String.Format(md2html.Properties.Resources.DirectiveNameMustFollowSingleSpaceErrorMessage, entry.FileName, entry.LineNumber, entry.Line));
            }

            string directiveName;

            string[] directiveArguments;

            int indexOfSpace = directiveLine.IndexOf(' ');

            if (indexOfSpace == 0)
            {
                directiveName      = directiveLine;
                directiveArguments = new string[0];
            }
            else
            {
                directiveName      = directiveLine.Substring(0, indexOfSpace);
                directiveArguments = SplitArguments(directiveLine.Substring(indexOfSpace + 1));
            }

            switch (directiveName)
            {
            case "title":
                return(ProcessTitleDirective(entry, directiveArguments));

            case "ignore":
                return(ProcessIgnoreDirective(entry, directiveArguments));

            default:
                throw new ErrorMessageException(String.Format(Properties.Resources.UnknownDirectiveErrorMessage, directiveName, entry.FileName, entry.LineNumber, entry.Line));
            }
        }