early alpha

main
dig 1 year ago
commit ecd89e38e1

@ -0,0 +1,65 @@
# depot > initiative
/d[ée]p[ôo]t(s*)/ig:
"${capital(_)? 'I' : 'i'}nitiative${$1}"
/de initiative(s*)/ig: "
${$1? 'des ' : \"d'\"}initiative${$1}"
/nouveau(x*) initiative(s*)/ig:
"${capital(_)? 'N' : 'n'}ouvelle${$1?'s':''} initiative${$2}"
# ce initi.
/ce initiative(s*)/ig:
"${capital(_)? 'C' : 'c'}ette initiative${$1}"
# d'un init
/d'un initiative(s*)/ig:
d'une initiative${$1}
# un init
/un initiative(s*)/ig:
une initiative${$1}
# le init
/\sle initiative(s*)/ig:
" l'initiative${$1}"
# du init
/du initiative/ig:
de l'initiative
/initiative distant/gi:
${_}e
/visiblity_helper_forced=.*$/m:
visiblity_helper_forced=L'administrateur du site a forcé toutes les nouvelles initiatives à être <span class="ui red text">privées</span>
# propriétaire > initiateur
/propri[eé]taire(s*)/gi:
#"${_[0]=='P' ?'I' :'i'}nitiateur${$1}"
${_[0]=='P' && 'I' || 'i'}nitiateur${$1}
# fork > dérivé
/fork(s*)/gi:
dérivé${$1}
# gogs > ?
/gogs/gi:
gilet.jaune.legal
# branch >
# commit > amandement
/commit/gi:
amandement
# merge >
# ticket > problème

@ -0,0 +1,77 @@
const yaml = require('js-yaml')
const fs = require('fs')
const params = process.argv.splice(2)
const vocab = yaml.safeLoad( fs.readFileSync('legal.yaml', 'utf8') )
const po = fs.readFileSync( params[0], 'utf-8')
console.log(params)
//process.exit()
const capital = s=> /^[A-Z]/.test(s)
const replace = vocab=> text=>
Object.keys( vocab )
.reduce( (text, reg,s,mod)=>
text.replace( eval(reg)
// RegExp(
// ( s = reg.split('/').filter(s=>s),
// console.log(s),
// mod = s.pop(),
// s.join('/') )
// , mod )
, /=>/.test( vocab[reg] )
? eval( vocab[reg] )
: eval( "(_,$1,$2,$3,$4,$5,$6,$7,$8,$9)=> `"+vocab[reg]+"`" )
// , new Function('_,$1,$2,$3,$4,$5,$6,$7,$8,$9', "return `"+vocab[reg]+"`")
)
, text
)
const legalize = replace( vocab )
console.log( legalize(po) )
process.exit()
replace({
[/test(s*)/ig]:
(_ ,s )=>
`${_.toUpperCase()}${s}`
, [/projet(s*)/ig]:
(_ ,s )=>
`projeeeeeet${s}`
})("coucou tests pRojets !!")
let legal = po.replace(
/d[ée]p[ôo]t(s*)/ig,
(depot ,s )=>
//console.log(depot,depot.test(capital),s)||
`${capital(depot)? 'I' : 'i'}nitiative${s}`
)
.replace(
/de initiative(s*)/ig,
(de_initiative,s )=>
`${s? 'des ' : "d'"}initiative${s}`
)
.replace(
/nouveau(x*) initiative(s*)/ig,
(nouveau,x ,s )=>
`${capital(nouveau)? 'N' : 'n'}ouvelle${x?'s':''} initiative${s}`
)
//ce initi.
//d'un init
//un init
//le init
//du init
console.log( legal )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,14 @@
{
"name": "legalize",
"version": "1.0.0",
"description": "",
"main": "legalize.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"js-yaml": "^3.12.0"
}
}

@ -0,0 +1,8 @@
/cou(cou) monde(e*)(s*)/ig: ${$1}-${$2}-${3}
/test(s*)/ig: ${_.toUpperCase()}${$1}
/chier/g: faire popo
/pr\/ojet(s*)/ig: projeeeeeet${$1}
Loading…
Cancel
Save