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;
        }
Example #2
0
        private async Task SetDocumentAsync()
        {
            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(ProjectName, Version, true);
                }
                else
                {
                    Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);
                }
            }
            catch (DocumentNotFoundException)
            {
                return;
            }

            var converter = _documentConverterFactory.Create(Document.Format ?? ProjectFormat);

            var content = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, GetSpecificVersionOrLatest(), Document.LocalDirectory);

            content = converter.Convert(content);

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

            Document.Content = content;
        }
Example #3
0
        private async Task ConvertDocumentContentToHtmlAsync()
        {
            await SetDocumentPreferencesAsync();

            SetUserPreferences();

            UserPreferences.Add("Document_Language_Code", LanguageCode);
            UserPreferences.Add("Document_Version", Version);

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

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

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

            //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;
        }
Example #4
0
        public async Task OnGet()
        {
            var projectDto = await _projectAppService.FindByShortNameAsync(ProjectName);

            ProjectFormat = projectDto.Format;

            DocumentNameWithExtension = DocumentName + "." + projectDto.Format;

            var versions = await _documentAppService.GetVersions(projectDto.ShortName, projectDto.DefaultDocumentName,
                                                                 projectDto.ExtraProperties, projectDto.DocumentStoreType, DocumentNameWithExtension);

            Versions = versions.Select(v => new VersionInfo(v, v)).ToList();

            AddDefaultVersionIfNotContains();

            var latestVersion = Versions.Count == 1 ? Versions[0] : Versions[1];

            latestVersion.DisplayText = $"{latestVersion.Version} - latest";
            latestVersion.Version     = latestVersion.Version;


            var versionFromUrl = Versions.FirstOrDefault(v => v.Version == Version);

            if (versionFromUrl != null)
            {
                versionFromUrl.IsSelected = true;
            }
            else if (string.Equals(Version, "latest", StringComparison.InvariantCultureIgnoreCase))
            {
                latestVersion.IsSelected = true;
            }
            else
            {
                Versions.First().IsSelected = true;
            }

            if (Version == null)
            {
                Version = Versions.Single(x => x.IsSelected).Version;
            }

            Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);

            var converter = _documentConverterFactory.Create(Document.Format ?? projectDto.Format);
            var content   = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, Document.Version, Document.LocalDirectory);

            content = converter.Convert(content);

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

            Navigation = await _documentAppService.GetNavigationDocumentAsync(ProjectName, Version, false);

            Navigation.ConvertItems();
        }
Example #5
0
        private async Task SetDocumentAsync()
        {
            Document = await _documentAppService.GetByNameAsync(ProjectName, DocumentNameWithExtension, Version, true);

            var converter = _documentConverterFactory.Create(Document.Format ?? ProjectFormat);
            var content   = converter.NormalizeLinks(Document.Content, Document.Project.ShortName, Document.Version, Document.LocalDirectory);

            content = converter.Convert(content);

            content          = HtmlNormalizer.ReplaceImageSources(content, Document.RawRootUrl, Document.LocalDirectory);
            content          = HtmlNormalizer.ReplaceCodeBlocksLanguage(content, "language-C#", "language-csharp"); //todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
            Document.Content = content;
        }
Example #6
0
        private void ConvertDocumentContentToHtml()
        {
            var converter = _documentToHtmlConverterFactory.Create(Document.Format ?? Project.Format);
            var content   = converter.Convert(Project, Document, GetSpecificVersionOrLatest(), LanguageCode);

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

            //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;
        }