Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decluttering card does not handle text values with new line characters properly. #47

Open
2 tasks done
kulmegil opened this issue Feb 8, 2022 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@kulmegil
Copy link

kulmegil commented Feb 8, 2022

Checklist:

  • I updated to the latest version available
  • I cleared the cache of my browser

Release with the issue:
Home Assistant: 2022.2.3
decluttering card: 0.6.3
Probably a long time issue. It can be easily reproduced in v0.5 at least.

Last working release (if known):
?

Browser and Operating System:
Firefox 96.0.3 (windows 10)
Google Chrome 99.0 (windows 10)
HA mobile app 2022.1.1 (Android 11)

Description of problem:

Decluttering card does not handle text values with new line characters properly.

Error card with "Unexpected token in JSON at positon xxx" is shown in Lovelace.
"Unexpected token" error is thrown from JSON.parse() method is shown in browser console.

Javascript errors shown in the web inspector (if applicable):

6b28abc1.js:1 card custom:my-template-card SyntaxError: Unexpected token 
 in JSON at position 1130
    at JSON.parse (<anonymous>)
    at :8123/hacsfiles/decluttering-card/decluttering-card.js?hacstag=188686483063:870:16
    at MyTemplateCard.setConfig (:8123/hacsfiles/decluttering-card/decluttering-card.js?hacstag=188686483063:871:7)
    at MyTemplateCard.setConfig (:8123/local/my/templates-loader.js?ts=1640036327063&dashboard_url=lovelace-resources:76:20)
    at o (:8123/frontend_latest/6b28abc1.js:1:5675)
    at :8123/frontend_latest/6b28abc1.js:1:6389
    at c (:8123/frontend_latest/6b28abc1.js:1:6651)
    at s (:8123/frontend_latest/6b28abc1.js:1:6068)
    at y (:8123/frontend_latest/1f3f8c5c.js:150:3576)
    at i.value (:8123/frontend_latest/1f3f8c5c.js:222:9176)

Additional information:

Create markdown card in UI editor and make a simple template out of it.

'markdown-example':
  default:
    - content: >-
        The **Markdown** card allows you to write any text. You can style it **bold**,
        *italicized*, ~strikethrough~ etc. You can do images, links, and more.


        For more information see the [Markdown
        Cheatsheet](https://commonmark.org/help).
  card:
    type: markdown
    content: '[[content]]'
@kulmegil kulmegil added the bug Something isn't working label Feb 8, 2022
@ildar170975
Copy link

There is a workaround:

  decl_markdown_example:
    default:
      - CONTENT: >-
          The **Markdown** card allows you to write any text. You can style it
          **bold**, *italicized*, ~strikethrough~ etc. You can do images, links,
          and more.
          \n
          For more information see the [Markdown
          Cheatsheet](https://commonmark.org/help).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants