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.

trimCustomFragments and content in quotes

See original GitHub issue

I wonder if it’s somehow possible to tell trimCustomFragments to not trim inside quotes. Example:

"use strict";

console.log(require('.').minify(`
  <div id="list {{name}}-list">
    {{name}}
  </div>
`, {
  ignoreCustomFragments: [/{{.*?}}/],
  collapseWhitespace: true,
  trimCustomFragments: true,
}));

This results in a broken class attribute:

<div class="list{{name}}-list">{{name}}</div>

With trimCustomFragments set to false, the class is correct, but there’s whitespace (which leads to unwanted text nodes being created) on the tag content:

<div class="list {{name}}-list"> {{name}} </div>

I also attempted to set ignoreCustomFragments to include quotes through [/".*?{{.*?}}.*?"/], but that leads to a double quoting issue (while trimming correctly):

<div class=""list {{name}}-list"">{{name}}</div>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
silverwindcommented, May 28, 2017

Looking good, I’ll test that further.

One tweak: {{2,}.*?["'].*?}{2,} so it also matches {{{triple}}} and more curly pairs.

0reactions
alexlamslcommented, May 28, 2017

Thanks for letting me know of your use cases. Always good to keep tap especially around features which I don’t get to use myself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extended Rules for Using Quotation Marks - Purdue OWL
Inaccurate quotes not only defeat the purpose of using a quote, they may also constitute plagiarism. However, there are approved methods for altering...
Read more >
Quotation Marks for Emphasis
Quotation marks within an emphatic context should tell readers that the content in quotes means something other than what it usually would.
Read more >
quotes - CSS: Cascading Style Sheets - MDN Web Docs
The quotes CSS property sets how the browser should render ... The open-quote and close-quote values of the content property produce no ...
Read more >
Quotation Marks and Direct Quotations - University of Sussex
The use of quotation marks, also called inverted commas, is very slightly complicated by the fact that there are two types: single quotes...
Read more >
Punctuation: Quotation Marks | Writing Style Guide
Double quotation marks are used for direct quotations and titles of compositions such as books, plays, movies, songs, lectures and TV shows.
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