Example #1
0
        private async Task ConvertDocumentContentToHtmlAsync()
        {
            if (_uiOptions.SectionRendering)
            {
                await SetDocumentPreferencesAsync();

                SetAlternativeOptionLinksAsync();
                SetUserPreferences();

                var partialTemplates = await GetDocumentPartialTemplatesAsync();

                Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences, partialTemplates);
            }

            var converter = _documentToHtmlConverterFactory.Create(Document.Format ?? Project.Format);
            var content   = converter.Convert(Project, Document, GetSpecificVersionOrLatest(), LanguageCode);

            content = HtmlNormalizer.ReplaceImageSources(
                content,
                Document.RawRootUrl,
                Document.LocalDirectory
                );

            content = HtmlNormalizer.WrapImagesWithinAnchors(content);

            //todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
            content = HtmlNormalizer.ReplaceCodeBlocksLanguage(
                content,
                "language-C#",
                "language-csharp"
                );

            Document.Content = content;
        }