skip ../ from a file path using preg_replace - preg-replace

I have a css declaration
background: url(corners/bl.png) no-repeat left bottom !important;
and I need to add something before corners/bl.png using preg_replace
The problem is that I also have
background: url(../images/gray/topmenu/active_l.png) no-repeat left center;
and I need to skip this because it's contain ../ inside the url value.
What I need is to get the url value when the value is not containing ../ inside it. If it only contain / then get it and replace it, if ../ skip it.
here is the code which is working, except the ../ issue
$new_file_content = preg_replace("/(:|,)(\s*?.?\s?)(\s*\burl)(\s*()(['|\"]?)([^/|^'|^\"|^)]*)(['|\"]?)())/i", '$1$2$3$4$5'.implode("/",$file_path_explode)."/".'$6$7$8', $new_file_content);
I know I need to add another condition instead of
([^/|^'|^\"|^)]*)
but I can't figure it out how to add something like except ../ [^(../)] or...?
Thanks

Would doing something like:
$new_file_content = preg_replace("/url\([\s]*(([^\.]{2})[^\)]+)/i", "url(". implode("/",$file_path_explode) ."/$1", $new_file_content);
Fit what you need? It checks for the 'url(' specifically so you are only touching what you actually want to replace within your regex. Also won't match anything that starts with url(.

Related

Force GitHub pages to render numerical lists sequentially instead of restarting?

I noticed that when GitHub pages with mkdocs have text or images in between numbers it ignores the numbering in the source document and instead restarts numbering. See here for an example of this.
Is there a way to force mkdocs to render the numbers in the original document instead of inventing its own?
If you add them all as 1. space and text, then sub item as image with a tab, it should work. As an example:
1. Option 1
imgage or next text
1. Option 2
You can check this documentation built using mkdocs as an example.
As Zoran mentioned above that was part of it. Things I figured out:
Code must be double tabbed - you cannot use ```
Indented lists must also be double tabbed - I wasn't able to get a single tab to work
Images do not have to be tabbed - they can be in line with the above text
There should not be an empty line when an image follows a numbered list item BUT FOR CODE there must.
I still haven't completely figured out. mkdoc's behavior is not as predictable as regular markdown

wrong auto comments for scss in vscode

I'm having an issue with the auto comments in my .scss files. By auto comments I mean 'CTRL + /' to comment out the selected code. When I'm in my scss file and I do this, it adds the JS comments '//'. So the output looks like this:
body {
font-size: 1rem;
line-height: 1.4;
// overflow-x: hidden;
}
When it should be:
body {
font-size: 1rem;
line-height: 1.4;
/* overflow-x: hidden; */
}
If I rename the .scss file to .css then the auto comments work correctly. I'm guessing this has to do with a setting inside of VSCode, either user or workspace setting?
I believe this is working as expected, as SCSS supports both ways to comment, and I do not think there are any settings in Visual Studio Code you can change to change how the comment style works.
Ctrl + / is "Toggle Line Comment", which is the // way. If you want to comment using the multi-line comment format, you can instead highlight what it is you want to comment, and perform Shift + Alt + A.
However, there is another way to change how the Line Comments work:
Find where Visual Studio Code is installed on your system, and go to resources → app → extensions → scss
In the scss folder should be a "language-configurations.json" file. Open it.
Change the lineComment property to be either a blank string, or delete it outright.
"lineComment": ""
Save the file, and restart Visual Studio Code. Now when you perform Ctrl + /, it should comment using the style you prefer.
Please see the comments to #Timothy's answer. I have previously written an extension to deal with these issues, Custom Language Properties, that allows you to easily change things like line or block comments for many languages.
But setting lineComment to the OP's desired ["/*","*/"] did not work. In looking at the scss language configuration file, an array of values is not allowed for line comment values. But it works to delete the lineComment key or setting it to the empty string "".
However, although probably rare, any language configuration file can be overwritten whenever vscode updates and you would have to go back and change the file again. Hence the extension.
With this setting:
"custom-language-properties": {
"scss.comments.lineComment": ""
}
this accomplishes the same thing as editing the underlying language-configuration file. And fortunately, at least in this case, apparently vscode will apply the blockComment value when the lineComment value is missing or inappropriate. And fortunately that blockCcomment style is what the OP wanted.
That is valid comment syntax for SCSS, and it's probably the correct default.
Single-line comments (which start with //) are always removed from the compiled output, which is usually what you want.
Multi-line comments (/* comment */) are only removed in compressed mode.
Source: Sass: Comments

Instead of dotted line,Can we use solid line in JS TREE?

I want to use a solid line in the JS Tree structure instead of the dotted line.
Refer Screenshot
I can remove dotted line using the following code
$('#html').jstree().hide_dots();
But I want to change it from dotted to solid. Is there any way for it.?
Yes, it is possible to convert the dotted lines to a solid line. Unfortunately the lines are not text or svg. They are formed using the theme image below. If you're using the default theme, it's available in the themes/default directory as 32px.png.
You can edit this image to change the tree style.

How to display newline in TimelineItem control's text property?

We have a SAPUI5 timeline control, where we are showing the comments coming from server.
The issue is, if the comments contain a newline \n, then the Timeline control is not able to display the text in newline. Instead, it introduces space wherever \n is present.
We have tried formatting \n to unicode character also but that also didn't worked. Timeline control aggregates TimelineItem.
The control we are using is: https://ui5.sap.com/#/api/sap.suite.ui.commons.TimelineItem
Code snippet can be found at:
https://jsbin.com/kuluyehilu/edit?html,output
I inspected your example and came up with the following solution.
Since the text is embedded in a <span>, all unnecessary whitespace will be trimmed. What you can do is telling the span (via CSS) that it should display the whitespace anyway.
If you don't have a CSS file in your project yet, create one. Then add the following lines
div.sapSuiteUiCommonsTimelineItemShellBody>span {
white-space: pre;
}
This should do the trick.
JSBin: https://jsbin.com/feladeneso/1/edit?html,output
If you inspect the rendered element, you will see it actually put in the break:
<span id="__item0-realtext">x
y</span>
...but did not convert it to a <br/> tag. You cannot add the tag yourself since it will be escaped, either. Maybe you can try to override the renderer, and convert any line breaks to html breaks

What do I put instead of a space when changing directory?

C:\Users\First Last\
What do I replace the space with? I've tried multiple variations but nothing works.
C:\Users\First-Last\
C:\Users\First_Last\
C:\Users\First`Last\
add double quotes
cd "C:\Users\First Last\"