Skip to content

Commit 25c447f

Browse files
committed
fix(highlight.js): use prebuilt package
custom build is broken
1 parent 9d6fca2 commit 25c447f

File tree

12 files changed

+87
-180
lines changed

12 files changed

+87
-180
lines changed

Gulpfile.js

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ var svgmin = require('gulp-svgmin')
112112
*/
113113

114114
// Remove pre-existing content from output folders
115-
var cleanDist = function(done) {
115+
var cleanDist = function (done) {
116116
// Make sure this feature is activated before running
117117
if (!settings.clean) return done()
118118

@@ -143,13 +143,13 @@ var jsTasks = lazypipe()
143143
.pipe(dest, paths.scripts.output)
144144

145145
// Lint, minify, and concatenate scripts
146-
var buildScripts = function(done) {
146+
var buildScripts = function (done) {
147147
// Make sure this feature is activated before running
148148
if (!settings.scripts) return done()
149149

150150
// Run tasks on script files
151151
src(paths.scripts.input)
152-
.pipe(flatmap(function(stream, file) {
152+
.pipe(flatmap(function (stream, file) {
153153
// If the file is a directory
154154
if (file.isDirectory()) {
155155
// Setup a suffix variable
@@ -184,7 +184,7 @@ var buildScripts = function(done) {
184184
}
185185

186186
// Lint scripts
187-
var lintScripts = function(done) {
187+
var lintScripts = function (done) {
188188
// Make sure this feature is activated before running
189189
if (!settings.scripts) return done()
190190

@@ -201,24 +201,24 @@ var lintScripts = function(done) {
201201

202202
// pretty print all xml listings
203203
// articles not yet decided
204-
var prettyXml = function(done) {
204+
var prettyXml = function (done) {
205205
src(paths.xml.listings, { base: "./" })
206-
.pipe(muxml({
207-
stripComments: false,
208-
stripCdata: false,
209-
stripInstruction: false,
210-
saxOptions: {
211-
trim: true,
212-
normalize: true
213-
}
214-
}))
206+
.pipe(muxml({
207+
stripComments: false,
208+
stripCdata: false,
209+
stripInstruction: false,
210+
saxOptions: {
211+
trim: true,
212+
normalize: true
213+
}
214+
}))
215215
.pipe(dest("./"))
216-
// Signal completion
217-
done()
216+
// Signal completion
217+
done()
218218
}
219219

220220
// Process, lint, and minify Sass files
221-
var buildStyles = function(done) {
221+
var buildStyles = function (done) {
222222
// Make sure this feature is activated before running
223223
if (!settings.styles) return done()
224224

@@ -258,7 +258,7 @@ var buildStyles = function(done) {
258258
}
259259

260260
// Optimize SVG files
261-
var buildSVGs = function(done) {
261+
var buildSVGs = function (done) {
262262
// Make sure this feature is activated before running
263263
if (!settings.svgs) return done()
264264

@@ -272,7 +272,7 @@ var buildSVGs = function(done) {
272272
}
273273

274274
// Copy third-party dependencies from node_modules into resources
275-
var vendorFiles = function(done) {
275+
var vendorFiles = function (done) {
276276
// Make sure this feature is activated before running
277277
if (!settings.vendor) return done()
278278

@@ -282,11 +282,16 @@ var vendorFiles = function(done) {
282282

283283

284284
// copy vendor scripts
285-
src(['node_modules/bootstrap/dist/js/bootstrap.min.*', 'node_modules/@popperjs/core/dist/umd/popper.min.*'])
285+
src(['node_modules/bootstrap/dist/js/bootstrap.min.*', 'node_modules/@popperjs/core/dist/umd/popper.min.*', 'node_modules/@highlightjs/cdn-assets/highlight.min.js', 'node_modules/@highlightjs/cdn-assets/languages/xquery.min.js', 'node_modules/@highlightjs/cdn-assets/languages/dockerfile.min.js'])
286+
.pipe(dest(paths.scripts.output))
287+
288+
// copy pre-packed lang definitions for code highlighter
289+
// CSS Bash Makefile Diff JSON Markdown Perl SQL Shell Properties Less SCSS Puppet'
290+
src(['node_modules/@highlightjs/cdn-assets/languages/xquery.min.js', 'node_modules/@highlightjs/cdn-assets/languages/dockerfile.min.js', 'node_modules/@highlightjs/cdn-assets/languages/apache.min.js', 'node_modules/@highlightjs/cdn-assets/languages/http.min.js', 'node_modules/@highlightjs/cdn-assets/languages/nginx.min.js'])
286291
.pipe(dest(paths.scripts.output))
287292

288293
// copy vendor Styles
289-
src(['node_modules/bootstrap/dist/css/bootstrap.min.*', 'node_modules/highlight.js/styles/atom-one-dark.css'])
294+
src(['node_modules/bootstrap/dist/css/bootstrap.min.*', 'node_modules/@highlightjs/cdn-assets/styles/atom-one-dark.min.css'])
290295
.pipe(dest(paths.styles.output))
291296

292297
// copy vendor fonts
@@ -298,7 +303,7 @@ var vendorFiles = function(done) {
298303

299304

300305
// Copy static files into output folder
301-
var copyFiles = function(done) {
306+
var copyFiles = function (done) {
302307
// Make sure this feature is activated before running
303308
if (!settings.copy) return done()
304309

@@ -310,32 +315,6 @@ var copyFiles = function(done) {
310315
done()
311316
}
312317

313-
// Build and copy highlight.js
314-
var buildPack = function(done) {
315-
// Make sure this feature is activated before running
316-
if (!settings.hjs) return done()
317-
318-
// build highlight pack
319-
// see https://highlightjs.readthedocs.io/en/latest/building-testing.html
320-
// TODO currently building is bugged when using npm
321-
let command = 'cd node_modules/highlight.js'
322-
+ ' && npm install'
323-
+ ' && node tools/build Apache CSS HTTP JavaScript Bash Makefile PHP Diff JSON Markdown Perl SQL HTML Java Nginx Shell Properties Less SCSS Puppet Dockerfile xquery'
324-
325-
exec(command, (err, stdout, stderr)=> {
326-
console.log(stderr)
327-
console.log(stdout)
328-
329-
callback(err)
330-
})
331-
332-
src('node_modules/highlight.js/build/*pack.js')
333-
.pipe(dest(paths.scripts.output))
334-
335-
// Signal completion
336-
done()
337-
}
338-
339318
/**
340319
* Export Tasks
341320
*/
@@ -351,7 +330,6 @@ exports.default = series(
351330
buildStyles,
352331
buildSVGs,
353332
copyFiles,
354-
buildPack,
355333
prettyXml
356334
)
357335
)

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
"supertest": "^7.0.0"
5454
},
5555
"dependencies": {
56+
"@highlightjs/cdn-assets": "^11.11.1",
5657
"@neos21/bootstrap3-glyphicons": "^1.0.7",
5758
"@popperjs/core": "^2.11.8",
58-
"bootstrap": "^5.3.3",
59-
"highlight.js": "^11.11.1"
59+
"bootstrap": "^5.3.3"
6060
}
6161
}

src/main/frontend/copy/scripts/highlight.pack.js

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

src/main/xar-resources/data/docker/docker.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<code>.xar</code>
128128
app inside a build folder on the same level as your own
129129
<literal>Dockerfile</literal>. To get an image of an eXist-db instance with your app installed and running, you would then:</para>
130-
<programlisting xlink:href="listings/listing-2.txt"/>
130+
<programlisting language="docker" xlink:href="listings/listing-2.txt"/>
131131
<para>You should see something like this:</para>
132132
<programlisting xlink:href="listings/listing-3.txt"/>
133133
<para>The result is a new image of your app installed into eXist-db. Since you didn't provide further instructions it will simply reuse the
@@ -149,7 +149,7 @@
149149
<code>docker exec …
150150
</code>style commands from this readme, use
151151
<code>RUN</code>.</para>
152-
<programlisting xlink:href="listings/listing-4.txt"/>
152+
<programlisting language="docker" xlink:href="listings/listing-4.txt"/>
153153
<para>The above demonstrates different kind of operations available to you in a single stage build. You have just executed the
154154
<link xlink:href="java-admin-client">Java Admin Client</link>
155155
from inside a Dockerfile, which in turn allows you to run any XQuery code you want when modifying the eXist-db instance that will ship with your images. You can also chain multiple RUN commands.</para>
@@ -173,7 +173,7 @@
173173
begins a stage) is the simple example again from before. Such a setup ensures that non of your collaborators has to have
174174
<literal>java, nodeJS, ect</literal>
175175
installed, and is great for fully automated builds and deployment.</para>
176-
<programlisting xlink:href="listings/listing-5.txt"/>
176+
<programlisting language="docker" xlink:href="listings/listing-5.txt"/>
177177
<para>The basic idea behind multi-staging is that everything you need for building your software should be managed by docker, so that all collaborators can rely on one stable environment. In the end, and after how ever many stages you need, only the
178178
files necessary to run your app should go into the final stage. The possibilities are virtually endless, but with this example and the Dockerfile in this repo you should get a pretty good idea of how you might apply this idea to your own projects.</para>
179179
</sect2>

src/main/xar-resources/data/xqsuite/xqsuite.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357
<para>Here is an example using the above assertion library</para>
358358
<programlisting language="xquery" xlink:href="listings/assertion-lib.txt"/>
359359
<para>The output will look like this</para>
360-
<programlisting language="xquery" xlink:href="listings/custom-assertion-result.xml"/>
360+
<programlisting language="xml" xlink:href="listings/custom-assertion-result.xml"/>
361361

362362
<sect3 xml:id="custom-assertion-fallback">
363363
<title>Fallback for backwards compatibility</title>

src/main/xar-resources/modules/xsl/convert-db5.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216

217217
<xsl:when test="exists(@language)">
218218
<pre>
219-
<code class="{@language}">
219+
<code class="{concat('language-', @language)}">
220220
<xsl:value-of select="$contents"/>
221221
</code>
222222
</pre>

src/main/xar-resources/resources/scripts/highlight.pack.js

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

src/main/xar-resources/resources/styles/atom-one-dark.css

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

0 commit comments

Comments
 (0)