I have big css file and need regex(Notepad++) to get only elements and css selectors found by specific css value. In following example I need to get element and selector by value 123456
header #objectnav nav a {
border-right: solid 1px #c0c0c0;
border-left: solid 1px #f4f9ff;
color: #123456;
}
a:hover {
color: #654321;
}
#hints .hint {
background-color: #f4f9ff;
border: 1px solid #e0f0ff;
color: #123456;
margin: 0 0 30px 0;
position: relative;
}
on exit I expect following
header #objectnav nav a
color
#hints .hint
color
or, if possible
header #objectnav nav a^color
#hints .hint^color
I did this just for the challenge:
The following regex will find all the rules containing the text 123456 as a value:
[^{}\s][^{}]*\{[^}]*?[-\w]+\s*:[^;}]*?123456[^}]*\}
But that's just a basic regex. The more challenging part is that I wondered if it's possible to generate a report such as the one you asked for using nothing but Notepad++. It turns out it's possible.
Replace the following pattern:
\s*([^{}]+?)\s*\{[^}]*?(?(?=([-\w]+)\s*:[^;}]*?123456)[^}]*|[^}])*\}\s*
With the following replacement string:
(?2$1^$2:)
Or this one depending on the output you prefer:
(?2$1\r\n$2\r\n\r\n:)
I didn't test it extensively but it works for the test cases you provided.
Related
I'm using .mjml templates and VSCode. I had to install an extension for the highlighting to work correctly but I noticed by Prettier seems to transform inline CSS (which is pretty common in emails) from this:
p,
h1 {
color: #ffffff;
}
h1,
.text-h1 h1 {
font-size: 32px;
line-height: 1.1;
margin: 0 0 16px 0;
font-weight: 700;
}
to this:
p, h1 { color: #ffffff; } h1, .text-h1 h1 { font-size: 32px; line-height: 1.1; margin: 0 0 16px 0; font-weight: 700; }
The only way I was able to prevent this is by adding a <!-- prettier-ignore --> before the <mj-style> tag but I was wondering if there isn't a better way (configuration?) to get the same result without the extra markup.
See:
https://github.com/mjmlio/mjml/issues/2557
Is there a way to tell Prettier that the following "block" has a specific markup type?
Based on my research and also the lack of answers, it looks like the overall MJML tooling ecosystem is not in the best of states. I think for now the best option is to use the workaround I provided. Here is a detailed breakdown of the options available.
Style element <mj-style>: (most likely the best option)
<!-- prettier-ignore -->
<mj-style css-inline="inline" />
.content {
color: green !important;
}
</mj-style>
Pros:
Works in the online visual editor by copy/pasting the markup.
Cons:
No Prettier formatting (ref).
An external CSS file:
<mj-include path="./default.css" type="css" css-inline="inline" />
Pros:
You can import a CSS file that will get normal Prettier treatment.
Standard pattern where CSS lives outside the document.
Cons:
It also won't work with the online MJML editor tool without merging back your CSS file. This is very annoying and makes it hard to maintain.
<mj-include> can report miss flagged error depending on our your project is setup.
It does not work with the "official" VSCode plugin (you have to use this one).
MJML inline styles:
<mj-text color="#fff" padding="0" font-weight="400" font-size="16px" line-height="1.65" />
Pros:
You don't need CSS.
Cons:
You possibly will repeat a lot of the same style and maintenance can become problematic.
Style element <mj-class>:
<mj-class name="blue" color="blue" />
Pros:
Benefits from the re-usability of CSS without having to use CSS, avoiding Prettier issues.
Cons:
Not as flexible as CSS in terms of selectors which can lead to repetition and maintenance issues.
I am preforming the following ack-grep inside of a bash script and, while it mostly works .. I am getting inconsistent results. The line I am using is:
ack-grep '(?<=imageserver).*(?=png)'
This is Perl type Regex (supported by both ack_grep and plain grep) -- I am searching for everything between imageserver and png. While it mostly works -- I get inconsistent results IE:
Why is it that you'll see it matched the first umpteen lines, then it matches something that it (in theory) should have two or three matches WITHIN. It's obvious the last "block" should have been matched after the first iteration of png however it skipped it multiple times and finally settled --
So, the first couple returning are my desired result -- And the last highlighted block is the "bad" result. How do I get consistent results here? I'll paste some text that returns this result for copy/paste posterity (verifiable example). If you copy and paste the following into a text file, you should get the same results I am getting.
Is this a syntax error, a misunderstanding, or a bug? Hate when things should work but don't ... The banes of development.
.mobile_menu_icon { display:block;cursor:pointer;width:100%;height:40px;margin:0 auto;background-image:url('/imageserver/default_images/four_lines_40x19.png');
.button-error { display:inline-block;width:14px;height:13px;background:url('/imageserver/GlobalMedia/Icons/deleteIcon.png') no-repeat;background-size:16px 16px;background-position:center;opacity:1;transition:all ease-in-out 150ms; }
.button-finished { display:inline-block;width:14px;height:13px;background:url('/imageserver/GlobalMedia/Icons/checkmark.png') no-repeat;background-size:16px 16px;background-position:center; }
background:url('/imageserver/confirm/ie.png');
background:url('/imageserver/confirm/buttons.png') no-repeat;
background:url('/imageserver/confirm/buttons.png') no-repeat;
.capItem { width:30px;height:30px;background:url('/imageserver/styles/captchaShapesWhite.png');background-repeat:no-repeat;background-size:auto 35px;display:inline-block;margin:0 3px; }
.form_button_error { display:inline-block;width:14px;height:13px;background:url('/imageserver/GlobalMedia/Icons/deleteIcon.png') no-repeat;background-size:13px 13px;background-position:center;opacity:1;transition:all ease-in-out 150ms; }
.form_button_finished { display:inline-block;width:14px;height:13px;background:url('/imageserver/GlobalMedia/Icons/checkmark.png') no-repeat;background-size:16px 16px;background-position:center; }
#mega_slider_wrapper,.shadow{width:100%;position:relative}.nav-arrows,.nav-dots,.shadow{display:none}.nav-arrows a,.nav-dots span,.nav-options span{cursor:pointer;border-radius:50%}#mega_slider_wrapper{background:0 0;overflow:hidden}#mega_slider_wrapper img,.mega_slide_image{width:100%}.shadow{height:168px;margin-top:-110px;background:url(/imageserver/AdminMedia/moduleImages/megaslider/shadow.png) bottom center no-repeat;background-size:100% 100%;z-index:-1}.sb-description h3{text-shadow:1px 1px 1px rgba(0,0,0,.3)}.sb-description h3 a{color:#4a3c27;text-shadow:0 1px 1px rgba(255,255,255,.5)}.nav-arrows a{width:42px;height:42px;background:url(/imageserver/AdminMedia/moduleImages/megaslider/nav.png) top left no-repeat #cbbfae;position:absolute;top:50%;left:2px;text-indent:-9000px;opacity:.9;box-shadow:0 1px 1px rgba(255,255,255,.8)}.nav-arrows a:first-child{left:auto;right:2px;background-position:top right}.nav-arrows a:hover{opacity:1}.nav-dots{text-align:center;position:absolute;height:30px;width:100%;left:0}.nav-dots span{display:inline-block;width:16px;height:16px;margin:3px;box-shadow:0 1px 1px rgba(255,255,255,.6),inset 0 1px 1px rgba(0,0,0,.1)}.nav-dots span.nav-dot-current{box-shadow:0 1px 1px rgba(255,255,255,.6),inset 0 1px 1px rgba(0,0,0,.1),inset 0 0 0 3px #cbbfae,inset 0 0 0 8px #fff}.nav-options{width:70px;height:30px;position:absolute;right:70px;bottom:0;display:none}.nav-options span{width:30px;height:30px;background:url(/imageserver/AdminMedia/moduleImages/megaslider/options.png) top left no-repeat #cbbfae;text-indent:-9000px;opacity:.7;display:inline-block}.sb-slider,.sb-slider li>img{width:100%}.nav-options span:first-child{background-position:-30px 0;margin-right:3px}.nav-options span:hover{opacity:1}.sb-slider{margin:0 auto;position:relative;overflow:hidden;list-style-type:none;padding:0;max-width:2000px!important}.sb-slider li{margin:0;padding:0;display:none}.sb-slider li>a{outline:0}.sb-slider img{max-width:100%;display:block}.sb-description{width:100%;max-width:1124px;margin:0 auto;padding:30px 10px 10px;height:900px;top:0;left:10px;right:10px;z-index:10;position:absolute;color:#fff;-webkit-transition:all .2s;-moz-transition:all .2s;-o-transition:all .2s;-ms-transition:all .2s;transition:all .2s;background:rgba(40,40,40,.2);text-shadow:#000 0 0 7px}.sb-description h2,.sb-description h3{line-height:1.1;margin:4px 0;padding:4px 0}.nav-dots span,.slider_button{transition:all ease-in-out 180ms}.sb-description h2{font-size:42px}.sb-description h3{font-size:22px}.sb-perspective{position:relative}.sb-perspective>div{position:absolute;-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-o-transform-style:preserve-3d;-ms-transform-style:preserve-3d;transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-o-backface-visibility:hidden;-ms-backface-visibility:hidden;backface-visibility:hidden}.sb-side{margin:0;display:block;position:absolute;-moz-backface-visibility:hidden;-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-o-transform-style:preserve-3d;-ms-transform-style:preserve-3d;transform-style:preserve-3d}.nav-arrows,.nav-arrows a,.nav-dots{z-index:11!important}.nav-arrows a{margin-top:-60px!important;background-color:rgba(0,0,0,.8);margin-left:10px;margin-right:10px}.nav-dots{bottom:0!important;background:rgba(0,0,0,.8);padding:8px}.nav-dots span{background:#777}.nav-dots span:hover{background:#aaa}.slider_button{position:relative;display:inline-block;line-height:1;width:auto;padding:10px 16px;background:#1F1E1E;border-radius:5px;color:#fff;text-decoration:none;margin:12px 0 0;font-size:16px}.slider_button:hover{background:#333}#media (max-width:1170px){.sb-description{width:85%!important;min-width:auto!important;margin:0 60px;box-sizing:border-box}}#media (max-width:850px){.sb-description{width:80%!important;min-width:auto!important;margin:0 60px;box-sizing:border-box}.sb-description h2,.sb-description h3{line-height:1.1;margin:4px 0;padding:4px 0}.sb-description h2{font-size:28px}.sb-description h3{font-size:14px}}#media (max-width:650px){.sb-description{width:75%!important;min-width:auto!important;margin:0 60px;box-sizing:border-box}}#media (max-width:600px){.hide_in_mobile{display:none}}
<div class="logo"><img src="/imageserver/UserMedia/zakattack/Logo.png" /></div>
<div class="mobile_logo"><img src="/imageserver/UserMedia/zakattack/mobile.png" alt="Logo" /></div>
<div class="powered_by">Powered by <img src="/imageserver/UserMedia/ywpgallery/ywpLogo.png" style="max-height:25px;vertical-align:middle;" alt="Your Web Pro | Roofing and Contractor Websites" title="On-Line Showrooms for Roofers & Contractors"></div>
The problem with your version of the regex is that it is greedy, which means .* consumes all characters until the end of the line and performs a backtracking then. That's why in your broken part (the long yellow line) the expression matches everything between 'imageserver' and the last 'png'.
A slight modification can make your regex non-greedy; just add a ? after the quantifier. Then the new regex will also search for a preceding 'imageserver' but it directly checks for each following character if a 'png' sequence is following. So, it only consumes and matches the text until the first 'png' sequence.
The example with the new regex (?<=imageserver).*?(?=png) and your text can be found here: https://regex101.com/r/FvSwg4/1
It is also a good idea to have a look at the regex-debugger view for the example. Then one can better understand the single steps that have to be performed for the matching.
I would like to set my ion-select with 100% of width.
I have tried with css class like this:
.mySelect { width: 100% !important; }
But it is not working.
I did it.
For someone who wants the solution, here is the code:
.myCustomSelect{
max-width: 100% !important;
}
You must have to override the 'max-width' css property.
Increasing the specificity of the selector allows for doing it without the !important on it:
ion-select.myCustomSelect{
width: 100%;
max-width: 100%;
}
Which makes it a bit cleaner, since !important should be used as sparingly as possible, as noted in the Stack Overflow article here:
Should I avoid using !important in CSS?
You don't need !important at all! Ionic has specified a min-width of 45% (or whatever as per your version of ionic). All you have to do is over-ride it with a max-width of 100%. At the same time, the select, being an inline element, will only expand to fit its contents. So it won't fill the whole width. So to make this happen, you simply add width: 100% to it. So your final CSS class may look something like this:
.full-width-select {
width: 100%;
max-width: 100%;
}
I try the each solutions but found a perfect way to do this :)
just modify your sass file by adding this
ion-select{
max-width: 70% !important;// your choice :)
}
The answer from Luis Antonio Pestana is good if you associate it with the code of his initial question. So to be more clear, the complete code to get the ion-select to take 100% of its container is :
.your_ion_select {
max-width: 100% !important;
width: 100% !important;
}
This is what helped me. After perusing multiple articles, I've found in this stack overflow article ~ Styling ion-select with popover interface, that if you open the developer tools and use the inspect tool, you can see the class that directly affects the select option.
So now that we know that the classes are .alert-wrapper.ion-overlay-wrapper.sc-ion-alert-md we can then add adjust this in our global.scss file
Like so
:root{
.alert-wrapper.ion-overlay-wrapper.sc-ion-alert-md{
max-width: 100% !important;
width: 100% !important;
}
I'm currently working with Ionicv4 and above, however I'm assuming this should still be of assistance
I am using CKeditor in my application.When i save content of the CKEditor output is added with tags like this.
<B>Summary:</B>
<P><BR><SPAN style="TEXT-ALIGN: left; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; LETTER-SPACING: normal; DISPLAY: inline !important; FONT: 15px/20px Helvetica, Arial, sans-serif; WHITE-SPACE: normal; ORPHANS: 2; FLOAT: none; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">The company's latest tweet simply states that "our team continues to investigate, but at this time, we're still unable to confirm that any security breach has occurred. Stay tuned here."</SPAN></P><BR>
<P><BR>Facebook : http://www.facebook.com</P><BR>
How Can I remove all the "break" tags out of above sample using regular exression in javascript.
Upon Save Text should be appended to "Summary : " like here
Summary: Call back the department if you have not heard from them.The initial story was triggered after a user in a Russian forum
claimed that he hacked and uploaded almost 6.5 millionThe initial
story was triggered after a user in a Russian forum claimed that he
hacked and uploaded almost 6.5 million
But now it's coming like this
Summary:
The initial story was triggered after a user in a Russian forum
claimed that he hacked and uploaded almost 6.5 millionThe initial
story was triggered after a user in a Russian forum claimed that he
hacked and uploaded almost 6.5 million
I am using replace(/[\n\r\f]/g, ' ') ;
replace(/\<!>[\s\S]*?\<!>/ig, '')
but no use.help me.
Finally
CKEDITOR.instances.editor1.getData().replace(/(\r\n|\n|\r)/gm,"");
worked perfectly for my issue.
Thanks.
replace(/[\n\r\f]/g, ' ') ;
will remove actual newlines not the coded ones
try
replace(/<BR>/g, '') ;
or if you want to remove all tags
replace(/<[^>]*?>/g, ' ') ;
I have a Django view that renders a piece of text and word wraps it. I am using the below CSS. When I convert the same to PDF using PISA, I dont see the word wrap and text is lost.
Do I need to set any properties on PISA for this?
{
margin-left: 20px;
padding: 0;
font-size: 12;
font-family: "Lucida Grande","DejaVu Sans","Bitstream Vera Sans",Verdana,Arial,sans-serif;
color: #333;
word-wrap: break-word;
}
Keep in mind that Pisa does not use CSS itself, it just implemented some of the CSS syntax and properties to apply its own rules in PDF generation.
See the section 6, Cascading Style Sheets, of the manual for the supported properties. And take a look at this nice manual, that is a little bit more detailed.
It's hard to find good documentation about pisa.