UNPKG

@riotjs/compiler

Version:

Compiler for Riot.js .riot files

14 lines (12 loc) 614 B
import getLineAndColumnByPosition from './get-line-and-column-by-position.js' /** * Add the offset to the code that must be parsed in order to generate properly the sourcemaps * @param {string} input - input string * @param {string} source - original source code * @param {RiotParser.Node} node - node that we are going to transform * @return {string} the input string with the offset properly set */ export default function addLineOffset(input, source, node) { const { column, line } = getLineAndColumnByPosition(source, node.start) return `${'\n'.repeat(line - 1)}${' '.repeat(column + 1)}${input}` }