Beispiel #1
0
        /// <summary>
        /// Exports the specified <see cref="TextDocument"/> to an external markdown file.
        /// </summary>
        /// <param name="document">The document to export.</param>
        /// <param name="fileName">Full name of the Html file to export to. Note that if exporting to multiple Html files,
        /// this is the base file name only; the file names will be derived from this name.</param>
        /// <param name="errors">A list that collects error messages.</param>
        public void Export(TextDocument document, string fileName, List <MarkdownError> errors)
        {
            if (null == document)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            var basePathName = Path.GetDirectoryName(fileName);

            if (ExpandChildDocuments)
            {
                document = ChildDocumentExpander.ExpandDocumentToNewDocument(document, errors: errors);
            }

            if (RenumerateFigures)
            {
                document.SourceText = FigureRenumerator.RenumerateFigures(document.SourceText);
            }

            // remove the old content
            if (EnableRemoveOldContentsOfOutputFolder)
            {
                var fullContentFolderName = basePathName;
                HtmlSplitRenderer.RemoveOldContentsOfContentFolder(fullContentFolderName);
            }

            // remove old images
            if (EnableRemoveOldContentsOfImageFolder)
            {
                var fullImageFolderName = Path.Combine(basePathName, ImageFolderName);
                HtmlSplitRenderer.RemoveOldContentsOfImageFolder(fullImageFolderName);
            }

            // First, export the images
            var(oldToNewImageUrl, listOfReferencedImageFileNames) = ExportImages(document, basePathName);

            // now export the markdown document as Html file(s)



            var renderer = new HtmlSplitRenderer(
                projectOrContentFileName: fileName,
                imageFolderName: ImageFolderName,
                splitLevel: SplitLevel,
                enableHtmlEscape: EnableHtmlEscape,
                autoOutline: false,
                enableLinkToPreviousSection: EnableLinkToPreviousSection,
                linkToPreviousSectionLabelText: LinkToPreviousSectionLabelText,
                enableLinkToNextSection: EnableLinkToNextSection,
                linkToNextSectionLabelText: LinkToNextSectionLabelText,
                enableLinkToTableOfContents: EnableLinkToTableOfContents,
                linkToTableOfContentsLabelText: LinkToTableOfContentsLabelText,
                imagesFullFileNames: listOfReferencedImageFileNames,
                oldToNewImageUris: oldToNewImageUrl,
                bodyTextFontFamily: BodyTextFontFamily,
                bodyTextFontSize: BodyTextFontSize
                );

            renderer.Render(document.SourceText);
        }
Beispiel #2
0
 public HtmlSplit_LinkInlineRenderer(HtmlSplitRenderer parent)
 {
     SplitRenderer = parent;
 }