Skip to content

Commit 5bf1067

Browse files
committed
added basedir option, removed svg dependency and builtin plugin
1 parent 6289578 commit 5bf1067

10 files changed

Lines changed: 26 additions & 142 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"mermaid": "^8.0.0-rc.8",
3434
"node-sass": "^4.9.0",
3535
"pug": "^2.0.3",
36-
"puppeteer": "^1.5.0",
37-
"svgo": "^1.0.5"
36+
"puppeteer": "^1.5.0"
3837
},
3938
"devDependencies": {
4039
"diff": "^3.5.0",

‎src/builtin_plugins/index.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const bibliography = require('./bibliography')
22
const chartjs = require('./chartjs')
3-
const svg = require('./svg')
43
const table = require('./table')
54
const mathjax = require('./mathjax')
65
const vegalite = require('./vegalite')
@@ -14,7 +13,6 @@ const katex = require('./katex')
1413
exports.plugins = {
1514
bibliography,
1615
mathjax,
17-
// svg,
1816
katex
1917
}
2018

‎src/builtin_plugins/svg/index.js‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎src/builtin_plugins/svg/mixins.pug‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎src/builtin_plugins/svg/optimizeSVG.js‎

Lines changed: 0 additions & 72 deletions
This file was deleted.

‎src/index.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ program
2323
.option('-t, --temp [location]', 'Directory for temp file')
2424
.option('--bo, --build-once', 'Build once only, do not watch')
2525
.option('-l, --locals <json>', 'Json locals for pug rendering')
26+
.option('--basedir <location>', 'Base directory for absolute paths, e.g. /')
27+
2628
.action(function (inp, out) {
2729
input = inp
2830
output = out
@@ -88,6 +90,8 @@ if (program.locals) {
8890
}
8991
}
9092

93+
94+
9195
// Google Chrome headless configuration
9296
const puppeteerConfig = {
9397
headless: true,
@@ -108,7 +112,8 @@ const puppeteerConfig = {
108112
const relaxedGlobals = {
109113
busy: false,
110114
config: {},
111-
configPlugins: []
115+
configPlugins: [],
116+
basedir: program.basedir || inputDir
112117
}
113118

114119
var updateConfig = async function () {

‎src/masterToPDF.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ exports.masterToPDF = async function (masterPath, relaxedGlobals, tempHTMLPath,
2828
html = pug.render(pluginPugHeaders + '\n' + masterPug, Object.assign({}, locals ? locals : {}, {
2929
filename: masterPath,
3030
fs: fs,
31+
basedir: relaxedGlobals.basedir,
3132
cheerio: cheerio,
32-
basedir: path.dirname(masterPath),
33+
__root__: path.dirname(masterPath),
3334
path: path,
3435
require: require,
3536
performance: performance,
4.17 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
h1 Hello !
2+
3+
style
4+
include:scss /tmp/absolute_path_test.scss

‎test/test.js‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const PDFImage = require('pdf-image').PDFImage
66
const PixelDiff = require('pixel-diff')
77
const JsDiff = require('diff')
88

9-
var assert = require('assert');
9+
var assert = require('assert')
10+
11+
fs.writeFile("/tmp/absolute_path_test.scss",
12+
"h1 {color: red; font-size: 140px; text-align:center;}")
1013

1114
describe('Sample tests', function () {
1215
var tests = [
@@ -40,6 +43,11 @@ describe('Sample tests', function () {
4043
{
4144
sampleName: 'utf8-characters',
4245
timeout: 10000
46+
},
47+
{
48+
sampleName: 'absolute_path',
49+
timeout: 10000,
50+
cmdOptions: ['--basedir', '/']
4351
}
4452
]
4553
tests.forEach(function (test) {
@@ -54,7 +62,10 @@ describe('Sample tests', function () {
5462
lastTestPNG: path.join(basedir, 'last_test_result.png'),
5563
html: path.join(basedir, 'master_temp.htm')
5664
}
57-
var process = spawn('relaxed', [paths.master, '--build-once', '--no-sandbox'])
65+
var process = spawn(
66+
'relaxed',
67+
[paths.master, '--build-once', '--no-sandbox'].concat(test.cmdOptions || [])
68+
)
5869
process.on('close', async function (code) {
5970
assert.equal(code, 0)
6071
var pdfImage = new PDFImage(paths.pdf, { combinedImage: true })

0 commit comments

Comments
 (0)