awk -F: '
/\{|\}|border|max-width|^$/ { print $0 }
!/\{|\}|border|max-width|^$/ {
split( substr($2, 1, length($2)-1) , a," ");
res = "";
for (i in a) {
ind = match(a[i], /[0-9]+px/)
if (ind != 0) {
a[i] = sprintf ("%.2frem", a[i]/10);
}
res=a[i] " " res;
}
res = substr(res, 1, length(res)-1);
print $1 ": " res ";"
}
' some.css
Arrays in awk are different—they are associative. This means that each array is a collection of pairs—an index and its corresponding array element value...
The pairs are shown in jumbled order because their order is irrelevant.
awk -F: '{
if ($0 ~ /\{|\}|border|max-width|^$/ ) { print $0 }
else {
res = "";
split( substr($2, 1, length($2)-1) , a, " ");
for (i=1; i<= length(a);i++) res = res " " ((match(a[i], /[0-9]+px/) != 0)? a[i]/10"rem" : a[i]);
print $1 ": " res";"
}
}' some.css
#!/bin/bash
css_file="$1"
while read -r line; do
if [[ $line == *"border"* || $line == *"max-width"* ]]; then
echo "$line"
continue
else
# Use regular expressions to find pixel values (e.g., "10px", "20px", etc.)
px_values=$(echo "$line" | grep -oE "[0-9]+px")
new_line="$line"
# Iterate through each found pixel value
for px_value in $px_values; do
# Extract the numeric value from the pixel value
numeric_value=$(echo "$px_value" | grep -oE "[0-9]+")
# Convert the pixel value to rem and divide by 10
rem_value=$(awk "BEGIN { printf \"%.2f\", $numeric_value / 10 }")
# Replace the pixel value with the calculated rem value
new_line=$(echo "$new_line" | sed "s/$px_value/${rem_value}rem/g")
# sed -i "s/$line/$new_line/" $css_file
done
# Print the modified line
echo "$new_line"
fi
done < "$css_file"
:options="{ scrollWheelZoom: false }"
@update:zoom="zoom = $event"
@wheel.native="onWheel"
methods: {
onWheel(e) {
if (e.deltaY < 0) {
this.zoom++;
e.preventDefault();
}
},
},
local mappings = {
n = {
["b"] = { "<Plug>Sneak_S", desc = "Sneak back" },
["<M-l>"] = { ":wa<CR>", desc = "close all" },
["<leader>;"] = { ":vsplit<CR>", desc = "split" },
["<S-l>"] = {
function() require("astronvim.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end,
desc = "Next buffer",
},
["<S-h>"] = {
function() require("astronvim.utils.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end,
desc = "Previous buffer",
},
},
i = {
["<C-l>"] = { "copilot#Accept('\\<CR>')", desc = "copilot expand", silent = true, expr = true, script = true },
},
}
-- Функция для удаления непечатных символов
local function removeNonPrintableChars(str)
return str:gsub("[%z\1-\31\127-\255]", "")
end
-- Удалить непечатные символы из значений таблицы mappings
for _, mode in pairs(mappings) do
for _, mapping in pairs(mode) do
if type(mapping) == "table" and mapping.desc then
mapping.desc = removeNonPrintableChars(mapping.desc)
end
end
end
return mappings
<C-r>= float(@l) / float(@h)
sed -r '
s/(className="[^"]+)([A-Z])([^"]+)([A-Z])([^"]+)([A-Z])([^"]+")/\1-\L\2\3-\L\4\5-\L\6\7/g;
s/(className="[^"]+)([A-Z])([^"]+)([A-Z])([^"]+")/\1-\L\2\3-\L\4\5/g;
s/(className="[^"]+)([A-Z])([^"]+")/\1-\L\2\3/g
' input_file > output_file
sed -i -r '
s/(className="[^"]+)([A-Z])([^"]+)([A-Z])([^"]+)([A-Z])([^"]+")/\1-\L\2\3-\L\4\5-\L\6\7/g;
s/(className="[^"]+)([A-Z])([^"]+)([A-Z])([^"]+")/\1-\L\2\3-\L\4\5/g;
s/(className="[^"]+)([A-Z])([^"]+")/\1-\L\2\3/g
' *.jsx