CSS parser / stringifier.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7002}{}\doxysection{Installation}\label{md_sfcode_node_modules_css_Readme_autotoc_md7002}
\begin{DoxyVerb}$ npm install css
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7003}{}\doxysection{Usage}\label{md_sfcode_node_modules_css_Readme_autotoc_md7003}

\begin{DoxyCode}{0}
\DoxyCodeLine{var css = require('css');}
\DoxyCodeLine{var obj = css.parse('body \{ font-\/size: 12px; \}', options);}
\DoxyCodeLine{css.stringify(obj, options); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7004}{}\doxysection{API}\label{md_sfcode_node_modules_css_Readme_autotoc_md7004}
\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7005}{}\doxysubsection{css.\+parse(code, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_css_Readme_autotoc_md7005}
Accepts a CSS string and returns an AST {\ttfamily object}.

{\ttfamily options}\+:


\begin{DoxyItemize}
\item silent\+: silently fail on parse errors.
\item source\+: the path to the file containing {\ttfamily css}. Makes errors and source maps more helpful, by letting them know where code comes from.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7006}{}\doxysubsection{css.\+stringify(object, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_css_Readme_autotoc_md7006}
Accepts an AST {\ttfamily object} (as {\ttfamily css.\+parse} produces) and returns a CSS string.

{\ttfamily options}\+:


\begin{DoxyItemize}
\item indent\+: the string used to indent the output. Defaults to two spaces.
\item compress\+: omit comments and extraneous whitespace.
\item sourcemap\+: return a sourcemap along with the CSS output. Using the {\ttfamily source} option of {\ttfamily css.\+parse} is strongly recommended when creating a source map. Specify `sourcemap\+: \textquotesingle{}generator'\`{} to return the Source\+Map\+Generator object instead of serializing the source map.
\item input\+Sourcemaps\+: (enabled by default, specify {\ttfamily false} to disable) reads any source maps referenced by the input files when generating the output source map. When enabled, file system access may be required for reading the referenced source maps.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7007}{}\doxysubsection{Example}\label{md_sfcode_node_modules_css_Readme_autotoc_md7007}

\begin{DoxyCode}{0}
\DoxyCodeLine{var ast = css.parse('body \{ font-\/size: 12px; \}', \{ source: 'source.css' \});}
\DoxyCodeLine{}
\DoxyCodeLine{var css = css.stringify(ast);}
\DoxyCodeLine{}
\DoxyCodeLine{var result = css.stringify(ast, \{ sourcemap: true \});}
\DoxyCodeLine{result.code // string with CSS}
\DoxyCodeLine{result.map // source map object }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7008}{}\doxysubsection{Errors}\label{md_sfcode_node_modules_css_Readme_autotoc_md7008}
Errors thrown during parsing have the following properties\+:


\begin{DoxyItemize}
\item message\+: {\ttfamily String}. The full error message with the source position.
\item reason\+: {\ttfamily String}. The error message without position.
\item filename\+: {\ttfamily String} or {\ttfamily undefined}. The value of {\ttfamily options.\+source} if passed to {\ttfamily css.\+parse}. Otherwise {\ttfamily undefined}.
\item line\+: {\ttfamily Integer}.
\item column\+: {\ttfamily Integer}.
\item source\+: {\ttfamily String}. The portion of code that couldn\textquotesingle{}t be parsed.
\end{DoxyItemize}

When parsing with the {\ttfamily silent} option, errors are listed in the {\ttfamily parsing\+Errors} property of the \href{\#stylesheet}{\texttt{ {\ttfamily stylesheet}}} node instead of being thrown.

If you create any errors in plugins such as in \href{https://github.com/reworkcss/rework}{\texttt{ rework}}, you {\bfseries{must}} set the same properties for consistency.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7009}{}\doxysection{AST}\label{md_sfcode_node_modules_css_Readme_autotoc_md7009}
Interactively explore the AST with \href{http://iamdustan.com/reworkcss_ast_explorer/}{\texttt{ http\+://iamdustan.\+com/reworkcss\+\_\+ast\+\_\+explorer/}}.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7010}{}\doxysubsection{Common properties}\label{md_sfcode_node_modules_css_Readme_autotoc_md7010}
All nodes have the following properties.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7011}{}\doxysubsubsection{position}\label{md_sfcode_node_modules_css_Readme_autotoc_md7011}
Information about the position in the source string that corresponds to the node.

{\ttfamily Object}\+:


\begin{DoxyItemize}
\item start\+: {\ttfamily Object}\+:
\begin{DoxyItemize}
\item line\+: {\ttfamily Number}.
\item column\+: {\ttfamily Number}.
\end{DoxyItemize}
\item end\+: {\ttfamily Object}\+:
\begin{DoxyItemize}
\item line\+: {\ttfamily Number}.
\item column\+: {\ttfamily Number}.
\end{DoxyItemize}
\item source\+: {\ttfamily String} or {\ttfamily undefined}. The value of {\ttfamily options.\+source} if passed to {\ttfamily css.\+parse}. Otherwise {\ttfamily undefined}.
\item content\+: {\ttfamily String}. The full source string passed to {\ttfamily css.\+parse}.
\end{DoxyItemize}

The line and column numbers are 1-\/based\+: The first line is 1 and the first column of a line is 1 (not 0).

The {\ttfamily position} property lets you know from which source file the node comes from (if available), what that file contains, and what part of that file was parsed into the node.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7012}{}\doxysubsubsection{type}\label{md_sfcode_node_modules_css_Readme_autotoc_md7012}
{\ttfamily String}. The possible values are the ones listed in the Types section below.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7013}{}\doxysubsubsection{parent}\label{md_sfcode_node_modules_css_Readme_autotoc_md7013}
A reference to the parent node, or {\ttfamily null} if the node has no parent.\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7014}{}\doxysubsection{Types}\label{md_sfcode_node_modules_css_Readme_autotoc_md7014}
The available values of {\ttfamily node.\+type} are listed below, as well as the available properties of each node (other than the common properties listed above.)\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7015}{}\doxysubsubsection{stylesheet}\label{md_sfcode_node_modules_css_Readme_autotoc_md7015}
The root node returned by {\ttfamily css.\+parse}.


\begin{DoxyItemize}
\item stylesheet\+: {\ttfamily Object}\+:
\begin{DoxyItemize}
\item rules\+: {\ttfamily Array} of nodes with the types {\ttfamily rule}, {\ttfamily comment} and any of the at-\/rule types.
\item parsing\+Errors\+: {\ttfamily Array} of {\ttfamily Error}s. Errors collected during parsing when option {\ttfamily silent} is true.
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7016}{}\doxysubsubsection{rule}\label{md_sfcode_node_modules_css_Readme_autotoc_md7016}

\begin{DoxyItemize}
\item selectors\+: {\ttfamily Array} of {\ttfamily String}s. The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments.
\item declarations\+: {\ttfamily Array} of nodes with the types {\ttfamily declaration} and {\ttfamily comment}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7017}{}\doxysubsubsection{declaration}\label{md_sfcode_node_modules_css_Readme_autotoc_md7017}

\begin{DoxyItemize}
\item property\+: {\ttfamily String}. The property name, trimmed from whitespace and comments. May not be empty.
\item value\+: {\ttfamily String}. The value of the property, trimmed from whitespace and comments. Empty values are allowed.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7018}{}\doxysubsubsection{comment}\label{md_sfcode_node_modules_css_Readme_autotoc_md7018}
A rule-\/level or declaration-\/level comment. Comments inside selectors, properties and values etc. are lost.


\begin{DoxyItemize}
\item comment\+: {\ttfamily String}. The part between the starting {\ttfamily /$\ast$} and the ending {\ttfamily $\ast$/} of the comment, including whitespace.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7019}{}\doxysubsubsection{charset}\label{md_sfcode_node_modules_css_Readme_autotoc_md7019}
The {\ttfamily @charset} at-\/rule.


\begin{DoxyItemize}
\item charset\+: {\ttfamily String}. The part following {\ttfamily @charset}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7020}{}\doxysubsubsection{custom-\/media}\label{md_sfcode_node_modules_css_Readme_autotoc_md7020}
The {\ttfamily @custom-\/media} at-\/rule.


\begin{DoxyItemize}
\item name\+: {\ttfamily String}. The {\ttfamily -\/-\/}-\/prefixed name.
\item media\+: {\ttfamily String}. The part following the name.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7021}{}\doxysubsubsection{document}\label{md_sfcode_node_modules_css_Readme_autotoc_md7021}
The {\ttfamily @document} at-\/rule.


\begin{DoxyItemize}
\item document\+: {\ttfamily String}. The part following {\ttfamily @document}.
\item vendor\+: {\ttfamily String} or {\ttfamily undefined}. The vendor prefix in {\ttfamily @document}, or {\ttfamily undefined} if there is none.
\item rules\+: {\ttfamily Array} of nodes with the types {\ttfamily rule}, {\ttfamily comment} and any of the at-\/rule types.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7022}{}\doxysubsubsection{font-\/face}\label{md_sfcode_node_modules_css_Readme_autotoc_md7022}
The {\ttfamily @font-\/face} at-\/rule.


\begin{DoxyItemize}
\item declarations\+: {\ttfamily Array} of nodes with the types {\ttfamily declaration} and {\ttfamily comment}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7023}{}\doxysubsubsection{host}\label{md_sfcode_node_modules_css_Readme_autotoc_md7023}
The {\ttfamily @host} at-\/rule.


\begin{DoxyItemize}
\item rules\+: {\ttfamily Array} of nodes with the types {\ttfamily rule}, {\ttfamily comment} and any of the at-\/rule types.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7024}{}\doxysubsubsection{import}\label{md_sfcode_node_modules_css_Readme_autotoc_md7024}
The {\ttfamily @import} at-\/rule.


\begin{DoxyItemize}
\item import\+: {\ttfamily String}. The part following {\ttfamily @import}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7025}{}\doxysubsubsection{keyframes}\label{md_sfcode_node_modules_css_Readme_autotoc_md7025}
The {\ttfamily @keyframes} at-\/rule.


\begin{DoxyItemize}
\item name\+: {\ttfamily String}. The name of the keyframes rule.
\item vendor\+: {\ttfamily String} or {\ttfamily undefined}. The vendor prefix in {\ttfamily @keyframes}, or {\ttfamily undefined} if there is none.
\item keyframes\+: {\ttfamily Array} of nodes with the types {\ttfamily keyframe} and {\ttfamily comment}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7026}{}\doxysubsubsection{keyframe}\label{md_sfcode_node_modules_css_Readme_autotoc_md7026}

\begin{DoxyItemize}
\item values\+: {\ttfamily Array} of {\ttfamily String}s. The list of “selectors” of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace.
\item declarations\+: {\ttfamily Array} of nodes with the types {\ttfamily declaration} and {\ttfamily comment}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7027}{}\doxysubsubsection{media}\label{md_sfcode_node_modules_css_Readme_autotoc_md7027}
The {\ttfamily @media} at-\/rule.


\begin{DoxyItemize}
\item media\+: {\ttfamily String}. The part following {\ttfamily @media}.
\item rules\+: {\ttfamily Array} of nodes with the types {\ttfamily rule}, {\ttfamily comment} and any of the at-\/rule types.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7028}{}\doxysubsubsection{namespace}\label{md_sfcode_node_modules_css_Readme_autotoc_md7028}
The {\ttfamily @namespace} at-\/rule.


\begin{DoxyItemize}
\item namespace\+: {\ttfamily String}. The part following {\ttfamily @namespace}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7029}{}\doxysubsubsection{page}\label{md_sfcode_node_modules_css_Readme_autotoc_md7029}
The {\ttfamily @page} at-\/rule.


\begin{DoxyItemize}
\item selectors\+: {\ttfamily Array} of {\ttfamily String}s. The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments.
\item declarations\+: {\ttfamily Array} of nodes with the types {\ttfamily declaration} and {\ttfamily comment}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7030}{}\doxysubsubsection{supports}\label{md_sfcode_node_modules_css_Readme_autotoc_md7030}
The {\ttfamily @supports} at-\/rule.


\begin{DoxyItemize}
\item supports\+: {\ttfamily String}. The part following {\ttfamily @supports}.
\item rules\+: {\ttfamily Array} of nodes with the types {\ttfamily rule}, {\ttfamily comment} and any of the at-\/rule types.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7031}{}\doxysubsection{Example}\label{md_sfcode_node_modules_css_Readme_autotoc_md7031}
CSS\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{body \{}
\DoxyCodeLine{  background: \#eee;}
\DoxyCodeLine{  color: \#888;}
\DoxyCodeLine{\} }

\end{DoxyCode}


Parse tree\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}type"{}: "{}stylesheet"{},}
\DoxyCodeLine{  "{}stylesheet"{}: \{}
\DoxyCodeLine{    "{}rules"{}: [}
\DoxyCodeLine{      \{}
\DoxyCodeLine{        "{}type"{}: "{}rule"{},}
\DoxyCodeLine{        "{}selectors"{}: [}
\DoxyCodeLine{          "{}body"{}}
\DoxyCodeLine{        ],}
\DoxyCodeLine{        "{}declarations"{}: [}
\DoxyCodeLine{          \{}
\DoxyCodeLine{            "{}type"{}: "{}declaration"{},}
\DoxyCodeLine{            "{}property"{}: "{}background"{},}
\DoxyCodeLine{            "{}value"{}: "{}\#eee"{},}
\DoxyCodeLine{            "{}position"{}: \{}
\DoxyCodeLine{              "{}start"{}: \{}
\DoxyCodeLine{                "{}line"{}: 2,}
\DoxyCodeLine{                "{}column"{}: 3}
\DoxyCodeLine{              \},}
\DoxyCodeLine{              "{}end"{}: \{}
\DoxyCodeLine{                "{}line"{}: 2,}
\DoxyCodeLine{                "{}column"{}: 19}
\DoxyCodeLine{              \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{          \},}
\DoxyCodeLine{          \{}
\DoxyCodeLine{            "{}type"{}: "{}declaration"{},}
\DoxyCodeLine{            "{}property"{}: "{}color"{},}
\DoxyCodeLine{            "{}value"{}: "{}\#888"{},}
\DoxyCodeLine{            "{}position"{}: \{}
\DoxyCodeLine{              "{}start"{}: \{}
\DoxyCodeLine{                "{}line"{}: 3,}
\DoxyCodeLine{                "{}column"{}: 3}
\DoxyCodeLine{              \},}
\DoxyCodeLine{              "{}end"{}: \{}
\DoxyCodeLine{                "{}line"{}: 3,}
\DoxyCodeLine{                "{}column"{}: 14}
\DoxyCodeLine{              \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{          \}}
\DoxyCodeLine{        ],}
\DoxyCodeLine{        "{}position"{}: \{}
\DoxyCodeLine{          "{}start"{}: \{}
\DoxyCodeLine{            "{}line"{}: 1,}
\DoxyCodeLine{            "{}column"{}: 1}
\DoxyCodeLine{          \},}
\DoxyCodeLine{          "{}end"{}: \{}
\DoxyCodeLine{            "{}line"{}: 4,}
\DoxyCodeLine{            "{}column"{}: 2}
\DoxyCodeLine{          \}}
\DoxyCodeLine{        \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{    ]}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_css_Readme_autotoc_md7032}{}\doxysection{License}\label{md_sfcode_node_modules_css_Readme_autotoc_md7032}
MIT 