Inheritance: IMarkdownToken
Esempio n. 1
0
        public virtual StringBuffer Render(IMarkdownRenderer render, AzureVideoBlockToken token, MarkdownBlockContext context)
        {
            StringBuffer content = StringBuffer.Empty;

            if (!context.Variables.TryGetValue("path", out object path))
            {
                path     = string.Empty;
                content += token.SourceInfo.Markdown;
                return(content += "\n\n");
            }

            if (!context.Variables.ContainsKey("azureVideoInfoMapping"))
            {
                Logger.LogWarning($"Can't fild azure video info mapping. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return(content + "\n\n");
            }

            var azureVideoInfoMapping = (IReadOnlyDictionary <string, AzureVideoInfo>)context.Variables["azureVideoInfoMapping"];

            if (azureVideoInfoMapping == null || !azureVideoInfoMapping.ContainsKey(token.VideoId))
            {
                Logger.LogWarning($"Can't fild azure video info mapping for file {path}. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return(content + "\n\n");
            }

            var azureVideoInfo = azureVideoInfoMapping[token.VideoId];

            content += $@"<iframe width=""{azureVideoInfo.Width}"" height=""{azureVideoInfo.Height}"" src=""{azureVideoInfo.Link}"" frameborder=""0"" allowfullscreen=""true""></iframe>";
            return(content + "\n\n");
        }
Esempio n. 2
0
        public virtual StringBuffer Render(IMarkdownRenderer render, AzureVideoBlockToken token, MarkdownBlockContext context)
        {
            StringBuffer content = StringBuffer.Empty;

            object path;
            if (!context.Variables.TryGetValue("path", out path))
            {
                path = string.Empty;
                content += token.SourceInfo.Markdown;
                return content += "\n\n";
            }

            if (!context.Variables.ContainsKey("azureVideoInfoMapping"))
            {
                Logger.LogWarning($"Can't fild azure video info mapping. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return content + "\n\n";
            }

            var azureVideoInfoMapping = (IReadOnlyDictionary<string, AzureVideoInfo>)context.Variables["azureVideoInfoMapping"];
            if (azureVideoInfoMapping == null || !azureVideoInfoMapping.ContainsKey(token.VideoId))
            {
                Logger.LogWarning($"Can't fild azure video info mapping for file {path}. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return content + "\n\n";
            }

            var azureVideoInfo = azureVideoInfoMapping[token.VideoId];
            content += $@"<iframe width=""{azureVideoInfo.Width}"" height=""{azureVideoInfo.Height}"" src=""{azureVideoInfo.Link}"" frameborder=""0"" allowfullscreen=""true""></iframe>";
            return content + "\n\n";
        }