1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 16:17:29 +00:00

Extract compile function to another file

This commit is contained in:
Cadence Ember 2020-07-20 13:52:56 +12:00
parent 496d53f47e
commit 1c382d6dc2
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412
2 changed files with 15 additions and 12 deletions

View File

@ -1,16 +1,5 @@
const compile = require("pug").compile
const data = {...require("./base")} const data = {...require("./base")}
const {pug} = require("./utils/functions")
/**
* @param {string} text
*/
function pug(text) {
let lines = text.split("\n")
while (lines[0] === "") lines.shift()
const indentLevel = lines[0].match(/^\t*/)[0].length
lines = lines.map(l => l.replace(new RegExp(`^\\t{0,${indentLevel}}`), ""))
return compile(lines.join("\n"))
}
;(() => { ;(() => {
data.go_to_profile = "Go to profile" data.go_to_profile = "Go to profile"

View File

@ -0,0 +1,14 @@
const compile = require("pug").compile
/**
* @param {string} text
*/
function pug(text) {
let lines = text.split("\n")
while (lines[0] === "") lines.shift()
const indentLevel = lines[0].match(/^\t*/)[0].length
lines = lines.map(l => l.replace(new RegExp(`^\\t{0,${indentLevel}}`), ""))
return compile(lines.join("\n"))
}
module.exports.pug = pug