Example #1
0
        public void CommandGenerator_ReturnsBaseCommand()
        {
            // Given
            var generator = new PandocCommandGenerator();

            // When
            var command = generator.GetCommand("test.md");

            // Then
            Assert.Equal("-f markdown \"test.md\"", command);
        }
Example #2
0
        public IPandocCommandGenerator BuildGenerator(PandocParameters parameters)
        {
            Log.Information($"Building generator with parameters : {parameters}");
            var validationResult = new PandocParametersValidator().Validate(parameters);

            if (!validationResult.IsValid)
            {
                Log.Error("Invalid Parameters !");
                throw new ArgumentException("Invalid parameters");
            }

            IPandocCommandGenerator generator = new PandocCommandGenerator();

            if (parameters.HighlightTheme)
            {
                generator = new HighlightPandocCommandOptionsGenerator(generator, parameters.HighlightThemeSource);
            }

            if (parameters.NumberedHeader)
            {
                generator = new NumberedHeaderPandocCommandOptionsGenerator(generator);
            }

            if (parameters.CustomFont)
            {
                generator = new FontPandocCommandGenerator(generator, parameters.CustomFontName);
            }

            generator = new GeometryPandocCommandGenerator(generator, "a4paper");

            if (parameters.CustomMargin)
            {
                generator = new MarginPandocCommandGenerator(generator, parameters.CustomMarginValue);
            }

            if (parameters.CustomPdfEngine)
            {
                generator = new PdfEnginePandocCommandGenerator(generator, parameters.CustomPdfEngineValue);
            }

            if (parameters.TableOfContents)
            {
                generator = new ContentTablePandocCommandGenerator(generator);
            }

            if (parameters.LogToFile)
            {
                generator = new LogsFileCommandGenerator(generator, parameters.LogFilePath);
            }

            return(generator);
        }