Home / Function/ parseInlineStyles() — astro Function Reference

parseInlineStyles() — astro Function Reference

Architecture documentation for the parseInlineStyles() function in parse-inline-styles.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  8f982432_73b1_f04a_91c2_0428eb006bad["parseInlineStyles()"]
  8d0ec02a_869f_2ca8_0956_919ef7eae75c["parse-inline-styles.ts"]
  8f982432_73b1_f04a_91c2_0428eb006bad -->|defined in| 8d0ec02a_869f_2ca8_0956_919ef7eae75c
  99ddcc46_a553_98f3_0a76_bd07adcd610e["trim()"]
  8f982432_73b1_f04a_91c2_0428eb006bad -->|calls| 99ddcc46_a553_98f3_0a76_bd07adcd610e
  style 8f982432_73b1_f04a_91c2_0428eb006bad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/markdoc/src/html/css/parse-inline-styles.ts lines 53–266

export function parseInlineStyles(style, options) {
	if (typeof style !== 'string') {
		throw new TypeError('First argument must be a string');
	}

	if (!style) return [];

	options = options || {};

	/**
	 * Positional.
	 */
	let lineno = 1;
	let column = 1;

	/**
	 * Update lineno and column based on `str`.
	 *
	 * @param {String} str
	 */
	function updatePosition(str) {
		let lines = str.match(NEWLINE_REGEX);
		if (lines) lineno += lines.length;
		let i = str.lastIndexOf(NEWLINE);
		column = ~i ? str.length - i : column + str.length;
	}

	/**
	 * Mark position and patch `node.position`.
	 *
	 * @return {Function}
	 */
	function position() {
		let start = { line: lineno, column: column };
		return function (node) {
			node.position = new Position(start);
			whitespace();
			return node;
		};
	}

	/**
	 * Store position information for a node.
	 *
	 * @constructor
	 * @property {Object} start
	 * @property {Object} end
	 * @property {undefined|String} source
	 */
	function Position(start) {
		this.start = start;
		this.end = { line: lineno, column: column };
		this.source = options.source;
	}

	/**
	 * Non-enumerable source string.
	 */
	Position.prototype.content = style;

	const errorsList = [];

	/**
	 * Error `msg`.
	 *
	 * @param {String} msg
	 * @throws {Error}
	 */
	function error(msg) {
		const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
		err.reason = msg;
		err.filename = options.source;
		err.line = lineno;
		err.column = column;
		err.source = style;

		if (options.silent) {
			errorsList.push(err);
		} else {
			throw err;
		}

Domain

Subdomains

Calls

Frequently Asked Questions

What does parseInlineStyles() do?
parseInlineStyles() is a function in the astro codebase, defined in packages/integrations/markdoc/src/html/css/parse-inline-styles.ts.
Where is parseInlineStyles() defined?
parseInlineStyles() is defined in packages/integrations/markdoc/src/html/css/parse-inline-styles.ts at line 53.
What does parseInlineStyles() call?
parseInlineStyles() calls 1 function(s): trim.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free