Sfoglia il codice sorgente

Change CV format to YAML instead of JSON

theenglishway (time) 2 anni fa
parent
commit
e69f674264
4 ha cambiato i file con 47 aggiunte e 4 eliminazioni
  1. 27 0
      README.md
  2. 16 2
      package-lock.json
  3. 2 1
      package.json
  4. 2 1
      to_pdf.js

+ 27 - 0
README.md

@@ -3,3 +3,30 @@
 Run `./run.sh` in development mode.
 
 Run `./to_pdf.js` in order to export the resume both in .html and .pdf formats
+
+## YAML syntax
+
+There are many ways to print a multi-line string in YAML, but this one seems the most natural 
+(beware of trailing spaces, though !) :
+
+```
+  summary: >-
+    The first line
+    which can
+    be written on many lines.
+
+    The second line which
+    can also be split.
+
+    The last line.
+```
+
+This will be parsed as :
+
+```
+    {
+    summary: 'The first line  which can  be written on many lines.\n' +
+        'The second line which can also be split.\n' +
+        'The last line.'
+    }
+```

+ 16 - 2
package-lock.json

@@ -1,5 +1,5 @@
 {
-  "name": "another_resume",
+  "name": "CV",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
@@ -9,7 +9,8 @@
         "html2pug": "^4.0.0",
         "jstransformer-markdown-it": "^3.0.0",
         "pug": "^3.0.2",
-        "puppeteer": "^20.8.3"
+        "puppeteer": "^20.8.3",
+        "yaml": "^2.3.4"
       }
     },
     "node_modules/@anduh/pug-cli": {
@@ -1528,6 +1529,14 @@
         "node": ">=10"
       }
     },
+    "node_modules/yaml": {
+      "version": "2.3.4",
+      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
+      "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
+      "engines": {
+        "node": ">= 14"
+      }
+    },
     "node_modules/yargs": {
       "version": "17.7.1",
       "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz",
@@ -2691,6 +2700,11 @@
       "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
       "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
     },
+    "yaml": {
+      "version": "2.3.4",
+      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
+      "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA=="
+    },
     "yargs": {
       "version": "17.7.1",
       "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz",

+ 2 - 1
package.json

@@ -4,6 +4,7 @@
     "html2pug": "^4.0.0",
     "jstransformer-markdown-it": "^3.0.0",
     "pug": "^3.0.2",
-    "puppeteer": "^20.8.3"
+    "puppeteer": "^20.8.3",
+    "yaml": "^2.3.4"
   }
 }

+ 2 - 1
to_pdf.js

@@ -2,11 +2,12 @@
 
 const fs = require('fs')
 const path = require('path')
+const yaml = require('yaml')
 
 const puppeteer = require('puppeteer')
 const pug = require('pug')
 
-const cv = require('./cv.json')
+const cv = yaml.parse(fs.readFileSync("./cv.yaml", { encoding: "utf8" }));
 
 function changeExt(filePath, new_) {
     parsed = path.parse(filePath)