1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-29 20:54:19 +00:00
This commit is contained in:
Maxime Moraine 2020-04-15 17:17:20 +02:00
parent 326c69d387
commit ccf8f9ad04
5 changed files with 0 additions and 37384 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,35 +0,0 @@
const path = require('path')
const fs = require('fs')
const directoryPath = path.join(__dirname, 'liste-objets-magiques')
fs.readdir(directoryPath, function (err, files) {
// Gestion d'erreur
if (err) {
return console.log('Unable to scan directory: ' + err)
}
// Traitement des fichiers
files.forEach(function (file) {
// On ignore les répertoires
let filePath = directoryPath+'/'+file
if (fs.lstatSync(filePath).isFile()) {
console.log(file)
let dirName = file.substring(0, file.length-3)
console.log(dirName)
fs.readFile(filePath, {encoding:'utf-8'}, (err, filecontent) => {
if (err) throw err
fs.mkdir(directoryPath+'/'+dirName, (err) => {
if (err) throw err
fs.writeFile(directoryPath + '/' + dirName + '/' + "README.md", filecontent, function(err) {
if(err) {
return console.log(err);
}
console.log("Saved: " + directoryPath + '/' + dirName + '/' + "README.md")
fs.unlink(filePath, (err) => {
if (err) throw err
})
})
})
})
}
})
})

View file

@ -1,39 +0,0 @@
const fs = require('fs')
const slugify = require('slugify')
slugify.extend({"'": '-'})
const items = require('./magic-items.json')
for (var i = 0; i < items.length; i++) {
let filecontent = buildFileContent(items[i])
let filename = slugify(items[i].header.title, {lower: true, strict: true})
fs.writeFile("./_magicitems/" + filename + ".md", filecontent, function(err) {
if(err) {
return console.log(err);
}
console.log("Saved: " + filename +".md")
})
}
function buildFileContent(item) {
let c = ''
// Frontmatter
c += '---\n'
c += 'title: "' + item.header.title + '"\n'
c += 'type: "' + item.header.magicitem.type + '"\n'
if (item.header.magicitem.subtype) {
c += 'subtype: "' + item.header.magicitem.subtype + '"\n'
} else {
c += 'subtype: false\n'
}
c += 'rarity: "' + item.header.magicitem.rarity + '"\n'
if (item.header.magicitem.attunement) {
c += 'attunement: "' + item.header.magicitem.attunement + '"\n'
} else {
c += 'attunement: false\n'
}
c += 'source: "' + item.header.taxonomy.source[0] + '"\n'
c += '---\n'
// Content
c += item.content
return c
}

File diff suppressed because one or more lines are too long

3
regex
View file

@ -1,3 +0,0 @@
# Search and replace spell links by Spell Toolips
search : \[_(.*)_\]\(\/grimoire\/(.*)\/\)
replace : <ST l="$1" s="$2" />