示例#1
0
        public void ConvertTextWithTrailingPeriod()
        {
            var md     = "Text text.";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            Assert.Equal(md, result);
        }
示例#2
0
        private string NormalizeActivityText(string textFormat, string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return(string.Empty);
            }

            // Default to markdown if it isn't specified.
            if (textFormat == null)
            {
                textFormat = TextFormatTypes.Markdown;
            }

            string plainText;

            if (textFormat.Equals(TextFormatTypes.Plain, StringComparison.Ordinal))
            {
                plainText = text;
            }
            else if (textFormat.Equals(TextFormatTypes.Markdown, StringComparison.Ordinal))
            {
                plainText = AlexaMarkdownToPlaintextRenderer.Render(text);
            }
            else // xml format or other unknown and unsupported format.
            {
                plainText = string.Empty;
            }

            if (!SecurityElement.IsValidText(plainText))
            {
                plainText = SecurityElement.Escape(plainText);
            }
            return(plainText);
        }
示例#3
0
        public void ConvertQuotesAndUrls()
        {
            var md     = "{   \"contentType\": \"image/jpeg\",   \"content\": \"https://somefantasticurl/\",   \"name\": \"Attachment1.jpg\" }";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            Assert.Equal("{   \"contentType\": \"image/jpeg\",   \"content\": \"https://somefantasticurl/\",   \"name\": \"Attachment1.jpg\" }.", result);
        }
示例#4
0
        public void ConvertTextBrAndParagraphsNoSpacesBetween()
        {
            var md     = "Same line.\nSame line.\n2nd line.\n\r3rd line.";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            Assert.Equal("Same line. Same line. 2nd line. 3rd line.", result);
        }
示例#5
0
        public void ConvertTextNoTrailingNewline()
        {
            var md     = "Text text";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            Assert.Equal("Text text.", result);
        }
示例#6
0
        public void ConvertTextLeadingTrailingWhitespace()
        {
            var md     = "         Text text            ";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            Assert.Equal("Text text.", result);
        }
示例#7
0
        public void ConvertTextWithNoTrailingPeriod()
        {
            var md     = "Text text";
            var result = AlexaMarkdownToPlaintextRenderer.Render(md);

            // Trailing period is added because it is a paragraph. Alexa TTS doesn't mind either way.
            Assert.Equal("Text text.", result);
        }