I'm using WebStorm version 2017.2.4 and I use postCSS syntax in files with .css extension. Is there any way to make WebStorm format code in these files like in files with .pcss extension?
Edit:
Code fomatting when postCSS dialect is set:
#import "../../../helpers/_helpers.css";
.block {
padding: $ step_4;
&__title {
font-size: $ font_size_6;
margin-bottom: $ step_4;
}
}
But it should be:
#import "../../../helpers/_helpers.css";
.block {
padding: $step_4;
&__title {
font-size: $font_size_6;
margin-bottom: $step_4;
}
}
How it looks in ide:
Install the PostCSS plugin, and then go to Settings | Languages & Frameworks | Stylesheets | Dialects, and make sure to set Project CSS Dialect to PostCSS
See https://www.jetbrains.com/help/webstorm/2017.2/dialects.html
Related
I want to parse the below html text string using shell script in bash.
<pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter-2</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter-1</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter0</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter1</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter2</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter3</pre>\n <pre style=\"font-family: helvetica, arial, sans-serif; white-space: pre-wrap; margin: 0;\">peter4</pre>\n
Expected output:
peter-2
peter-1
peter0
peter1
peter2
peter3
peter4
I want the shell command to extract values based on <pre tag and not based on position.
Assuming your input is always that regular and you can't use an XML parser for some reason and just want something cheap and cheerful then with a sed that accepts \n in the replacement text (e.g. GNU sed):
$ sed 's:</pre>:\n:g' file | sed -n 's/.*>//p'
peter-2
peter-1
peter0
peter1
peter2
peter3
peter4
Otherwise in bash with any sed:
$ sed 's:</pre>:\'$'\n'':g' file | sed -n 's/.*>//p'
peter-2
peter-1
peter0
peter1
peter2
peter3
peter4
or any awk in any shell:
$ awk '{gsub("</pre>","\n")}1' file | awk 'sub(/.*>/,"")'
peter-2
peter-1
peter0
peter1
peter2
peter3
peter4
# xml_read function
# usage: xml_read <filename> <attribute> [<tag>] (default is </string>)
xml_read () {
local filename="${1//\*/.\*}" attribute="${2//\*/.\*}" tag="${3//\*/.\*}" value
[ -n "${tag}" ] || tag=string
[ -n "${filename}" ] && [ -n "${attribute}" ] && \
value="$(grep -iwhoIrm1 "<${tag} name=\"${attribute}\">.*</${tag}>" "${filename}" 2> /dev/null | cut -d\> -f2)"
[ -n "${value}" ] && while [ "${value:(-1)}" != "<" ]; do value="${value%?}"; done
printf '%s' "${value%?}"
}
edit:
not sure about your input format \n is linefeed? cut works line based i have added a sed to modify the input file into readable format
your xml file looks different from mine. the ported function could look like this
#!bin/bash
# xml_read function
# usage: xml_read <filename> <attribute> [<tag>] (default is </string>)
xml_read () {
local filename="${1//\*/.\*}" attribute="${2//\*/.\*}" tag="${3//\*/.\*}" value
[ -n "${tag}" ] || tag=string
[ -n "${filename}" ] && [ -n "${attribute}" ] && \
grep -iwhoI "<${tag} ${attribute}=.*>.*</${tag}>" "${filename}" 2> /dev/null | cut -d\> -f2 | cut -d\< -f1
}
# evaluate linefeeds
sed -i 's,\\n,'\\n',g' test.xml
# call function
xml_read test.xml style pre
When I use an R script from the shell to render my bookdown document,
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
it touches all of the .Rmd files. Is there a way to render without touching the files so I don't have to reload them in my editor?
My _bookdown.yml file is:
new_session: yes
rmd_files: [
"index.Rmd",
"encoding.Rmd",
"includes.Rmd",
"comments.Rmd",
"whitespace.Rmd",
"types.Rmd",
"expressions.Rmd",
"statements.Rmd",
"blocks.Rmd",
"user-functions.Rmd",
"execution.Rmd",
"transforms.Rmd",
"syntax.Rmd"
]
before_chapter_script: "_common.R"
delete_merged_file: TRUE
and my _common.R is
library(ggplot2)
library(rstan)
set.seed(10101010)
options(digits = 3)
printf ",
collapse = TRUE,
cache = TRUE,
out.width = "70%",
fig.align = 'left',
fig.width = 6,
fig.asp = 0.618, # 1 / phi
fig.show = "hold"
)
The beginning of my index.Rmd file is:
---
title: "Stan Language Reference"
author: "Stan Development Team"
date: "Version 2.18 (May 2018)"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
bibliography: [../bibtex/all.bib]
biblio-style: "apalike"
link-citations: true
fontsize: 11pt
cover-image: img/logo_tm.png
url: 'http\://mc-stan.org/'
github-repo: stan-dev/stan
monofont: "Lucida Console"
description: "Stan reference manual specifying the syntax and semantics of the Stan programming language."
---
I just fixed this issue in bookdown 0.17.2 on Github. Your Rmd files will no longer be touched in future versions of bookdown. For now, you may install the dev version:
remotes::install_github('rstudio/bookdown')
I am having the following error when running Jest
SyntaxError: node_modules/my_styleguide/src/components/blocks/SegmentSetting.jsx: Unexpected token (46:10)
44 | ) {
45 | return (
> 46 | <p className="SettingDescr">{self.props.description}</p>
| ^
47 | )
48 | }
49 | }
The node_modules dependency is still in its es6 format. Jest doesn't seem to provide the option to transpile your node_modules, as it does with your actual app. Instead, jest ignores the node_modules folder.
The .bashrc file looks ok to me:
{
"presets": ["es2015", "react", "stage-0"]
}
How do you make Jest transpile your node_modules too? It would be the equivalent of the "--ignore false" flag that we have in mocha.
I would mark this as an answer rather than the answer.
I had a similar issue, multiple components in node_modules in ES2015 and in need of transpilation.
I updated transformIgnorePatterns to:
["/node_modules/(?!(our-react-components-.*?\\.js$))"]
The negative look-ahead for modules in our-react-components-* folders mean Jest (and therefore Babel) will find and transpile our shared components.
This was in an ejected Create React App project with Jest 20.0.4.
I installed grunt-text-replace with npm install grunt-text-replace --save-dev command and add grunt.loadNpmTasks('grunt-text-replace'); to gruntfile.js and add write this:
replace: {
example: {
src: ['css/mystyle.css'],
overwrite: true,
replacements: [{
from: 'wizard', // string replacement
to: 'wizardstep'
}]
}
}
then run grunt replace in command line and after that show me done, without error but my replacement doesn't work and applied.
Unfortunately I entered path incorrectly and other hand grunt-text-replace doesn't show me message if source file path incorrect.
just I correct source path
I am using imagekit and wkhtmltoimage to convert html to image. On my local server I am using ubuntu 14.10 and its working fine. But the live server is centos 6 and when I move the code to live server it is showing following libjpeg error:
error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
Complete error code:
Command failed: /root/.rbenv/versions/2.1.2/bin/wkhtmltoimage --height 470 --width 350 --transparent --quality 60 --format png - -: /root/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/wkhtmltoimage-binary-0.12.1/libexec/wkhtmltoimage-amd64: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
Here is my code in controller to create image:
html_content = "<div style='margin:-8px -2px 15px -8px;background:none repeat scroll 0 0 #{temp_params['color']}; direction: #{temp_params['direction']}; font-size: 22px;color: #fff;font-family:arial;line-height: 30px;padding: 15px; height: 470px;width:350px;border-radius: 4px;position:relative;text-align:center;display:table;'><div style='display:table-cell;vertical-align:middle;word-break:break-all;'>#{temp_params['text']}</div></div>"
file = Tempfile.new(["quote", '.png'], 'tmp', :encoding => 'ascii-8bit')
img = IMGKit.new(html_content, height: 470, width: 350, transparent: true, quality:60, :layout => false)
file.write(img.to_img(:png))
temp.attachment = file
file.unlink
temp.save
I have checked solutions provided on various links but none of them worked.