question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cards: unable to render D. M. YYYY date properly

See original GitHub issue

Screenshots

When Title or Subtitle in HeroCard starts with date in European format (D. M. YYYY):

image

It gets evaluated with Markdown as ordered list and produces wrong HTML:

image

image

Version

  • webchat-stable
  • Bot Framework emulator

Describe the bug

When Title or Subtitle in HeroCard begins with date in the form of D. M. YYYY it’s recognized as Markdown ordered list and rendered completely out of place (see screenshots).

To Reproduce

Steps to reproduce the behavior:

  1. Connect your bot to proper channel registration

  2. Start Bot Framework Emulator or deploy web chat to a website

  3. Make sure your regional settings are European D. M. YYYY

  4. Generate a Hero Card and set Title and/or Subtitle to today’s date

    var reply = stepContext.Context.Activity.CreateReply();
    var card = new HeroCard
    {
        Title = string.Format(DateTime.Now.ToShortDateString()),
        Subtitle = DateTime.Now.ToShortDateString(),
    };
    
    reply.Attachments.Add(card.ToAttachment());
    await stepContext.Context.SendActivityAsync(reply);
    
  5. Send it to user

  6. See incorrect display in Web Chat

Expected behavior

Date should be displayed properly, not as an ordered list.

Additional context

Workaround: Prepend date with invisible character ⁣

[Bug]

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

3reactions
tonyanzianocommented, Jun 27, 2019

@msimecek , the reason it converts 26. 6. 2019 into 1. 1. 2019 is because Markdown interprets a number followed by a . as one item in a list. Items in a list are enumerated in Markdown.

One special thing about how it interprets this syntax is that it does not matter what number is before the ., the list will start at 1 and increment upwards for each subsequent item in the list.

For example: try the following in the GitHub comment box and click “Preview” to see what it renders:

1.
3.
10.

This should render as:

Markdown also understands the concept of nested lists, which means that enumerated items with different indentations will be seen as sub-lists of the parent list.

So in the case of your hero card (feel free to try this in GitHub as well):

1. 1. year
1. 1. year

Will render as:

    1. year
    1. year

because the first 1. on each line is seen as the first item in the parent-level list, and the second 1. is seen as the first item in the child-level list for each row.

So when you type 26. 6. 2019, the 26. gets converted to a 1. and the 6. also gets converted into a 1. because they are both seen as the first item in an ordered list.

===

Regarding the actual issue, I will try to bump the Web Chat version within the Emulator and see if that fixes it.

2reactions
tdurnfordcommented, Jun 26, 2019

@tonyanziano Thanks for point that out! You can add a plain text attachment to the activity if you don’t want the string to be passed through the markdown renderer. I’m not sure that will work in an Hero Card though.

await context.sendActivity({
    attachments: [{
        content: "26. 6. 2019",
        contentType: 'text/plain'
    }]
})

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

[JavaScript][Localization] [Not Rendering dd/MM/yyyy correctly]
Hi Mike, Seems format of the date input needs to be given for proper date formatting. I have tried the ViewAC example and...
Read more >
Solved: Date Display Formats - Microsoft Power BI Community
The information is properly cast as 'date' within my source table and is rendering fine in the power query editor.
Read more >
Strtotime() doesn't work with dd/mm/YYYY format
I really like the strtotime() function, but the user manual doesn't give a complete description of the supported date formats. strtotime('dd/mm/ ...
Read more >
How to correct a #VALUE! error in the DATEVALUE function
Solution: Make sure that your system's date and time settings (both Short time and Long time) matches the date format in the date_text...
Read more >
Modify date and time formats in Zaps - Zapier Help
If you have an app that formats dates as MM/DD/YYYY but you need to send it to an app that formats dates as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found