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

Prevent escaping in all languages #985

Merged
merged 4 commits into from
Dec 14, 2018

Conversation

adamszalapski
Copy link
Collaborator

Jira

http://vjira2:8080/browse/BDS-543

Summary

Apply escaping to all languages in code snippet component.

Details

Changes are only in a js file. It's simple remove of variable and escape without checking language.

How to test

Run this code locally. Go to localhost:3000/pattern-lab. Navigate: Styleguide > Sassdocs > View All then on right navigation Tools: typhography > @mixin bolt-font-family and/or Tools: typhography > @mixin bolt-font-size and check if &, <, > are showed unescaped. You can create new pattern-lab page and apply to it: {% include "@bolt-components-code-snippet/code-snippet.twig" with { display: "block", lang: "html", content: "&lt;bolt-list&gt; &lt;bolt-list-item&gt;&lt;/bolt-list-item&gt; &lt;bolt-list-item&gt;&lt;/bolt-list-item&gt; &lt;bolt-list-item&gt;&lt;/bolt-list-item&gt; &lt;/bolt-list&gt;" } only %} to check if all languages are escaped please chenge lang and content variable.

@bolt-bot
Copy link
Collaborator

⚡ PR built on Travis and deployed a now preview here:

@mikemai2awesome
Copy link
Collaborator

@adam2661

I did some testing and it is still not working well. Take a look at the following:

✅ SCSS/CSS is working

scss

❌ HTML is not working as expected

html

There is a discrepancy between using the twig vs the web component, can this be fixed?

cc @danielamorse

Copy link
Collaborator

@danielamorse danielamorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikemai2awesome I setup the same test and got the same result. No space between tags. This is because the code-snippet twig template wraps the content in a spaceless tag. Whereas the web component skips that part. I'm not sure if it's safe to remove that spaceless tag or not. I think ideally we'd use spaceless plus some JS code prettifier?

@adam2661 this is the work @sghoweri did on this file. If you haven't seen this yet, I'm sorry I didn't link to it sooner! You might check it out and see if it solves the problem you are working on.

Copy link
Collaborator

@mikemai2awesome mikemai2awesome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working as expected with the usage of {%- verbatim -%}.

Copy link
Collaborator

@danielamorse danielamorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, works as expected. Approved!

@sghoweri sghoweri merged commit 3d84bf7 into master Dec 14, 2018
@sghoweri sghoweri deleted the bugfix/prevent-escaping-in-all-languages branch December 14, 2018 16:10
@sghoweri sghoweri mentioned this pull request Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants