/// <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 Maml file to export to. Note that if exporting to multiple Maml 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 = null) { 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); } // now export the markdown document as Maml file(s) // first parse it with Markdig var pipeline = new MarkdownPipelineBuilder(); pipeline = MarkdownUtilities.UseSupportedExtensions(pipeline); var markdownDocument = Markdig.Markdown.Parse(document.SourceText, pipeline.Build()); var renderer = new OpenXMLRenderer( wordDocumentFileName: OutputFileName, localImages: document.Images, textDocumentFolder: document.Folder ); if (MaximumImageWidth.HasValue) { renderer.MaxImageWidthIn96thInch = MaximumImageWidth.Value.AsValueIn(Altaxo.Units.Length.Inch.Instance) * 96.0; } if (MaximumImageHeight.HasValue) { renderer.MaxImageHeigthIn96thInch = MaximumImageHeight.Value.AsValueIn(Altaxo.Units.Length.Inch.Instance) * 96.0; } if (null != ThemeName) { renderer.ThemeName = ThemeName; } renderer.RemoveOldContentsOfTemplateFile = RemoveOldContentsOfTemplateFile; renderer.ImageResolution = ImageResolutionDpi; renderer.UseAutomaticFigureNumbering = UseAutomaticFigureNumbering; renderer.DoNotFormatFigureLinksAsHyperlinks = DoNotFormatFigureLinksAsHyperlinks; renderer.Render(markdownDocument); }