Visualize Your Ideas With Code
build: fix code highlighting in logs (#877)
Jacobffe43754b168
diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.ymlindex 22c91b6f..253a5681 100644--- a/.github/workflows/verify.yml+++ b/.github/workflows/verify.yml@@ -25,6 +25,7 @@ jobs:key: ${{ hashFiles('package-lock.json') }}-node-modulespath: |**/node_modules+ !**/node_modules/.cache~/.cache/puppeteer- run: npm ciif: steps.cache-npm.outputs.cache-hit != 'true'diff --git a/package-lock.json b/package-lock.jsonindex c5fee5c5..54cc9347 100644--- a/package-lock.json+++ b/package-lock.json@@ -16600,6 +16600,15 @@"node": ">= 12"}},+ "node_modules/marked-highlight": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.1.0.tgz",+ "integrity": "sha512-peBvgGZZqUw074Vy/N8Y7/6JQhSnR54/T0Ozq2/fAIBzcYfVfExFdQJptIhQxreR1elpwvJRrqhp6S/Prk8prA==",+ "dev": true,+ "peerDependencies": {+ "marked": ">=4 <12"+ }+ },"node_modules/mathjax-full": {"version": "3.2.2","resolved": "https://registry.npmjs.org/mathjax-full/-/mathjax-full-3.2.2.tgz",@@ -25287,6 +25296,7 @@"@rollup/plugin-typescript": "^11.1.5","highlight.js": "^11.9.0","marked": "^10.0.0",+ "marked-highlight": "^2.1.0","ts-patch": "^3.0.2"}},@@ -28989,6 +28999,7 @@"@rollup/plugin-typescript": "^11.1.5","highlight.js": "^11.9.0","marked": "^10.0.0",+ "marked-highlight": "^2.1.0","ts-patch": "^3.0.2"},"dependencies": {@@ -36928,6 +36939,13 @@"integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==","dev": true},+ "marked-highlight": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/marked-highlight/-/marked-highlight-2.1.0.tgz",+ "integrity": "sha512-peBvgGZZqUw074Vy/N8Y7/6JQhSnR54/T0Ozq2/fAIBzcYfVfExFdQJptIhQxreR1elpwvJRrqhp6S/Prk8prA==",+ "dev": true,+ "requires": {}+ },"mathjax-full": {"version": "3.2.2","resolved": "https://registry.npmjs.org/mathjax-full/-/mathjax-full-3.2.2.tgz",diff --git a/packages/internal/package.json b/packages/internal/package.jsonindex ca4066cc..f94110ed 100644--- a/packages/internal/package.json+++ b/packages/internal/package.json@@ -9,6 +9,7 @@"@rollup/plugin-typescript": "^11.1.5","highlight.js": "^11.9.0","marked": "^10.0.0",+ "marked-highlight": "^2.1.0","ts-patch": "^3.0.2"}}diff --git a/packages/internal/transformers/markdown-literals.js b/packages/internal/transformers/markdown-literals.jsindex a5a7a539..0a3bc93b 100644--- a/packages/internal/transformers/markdown-literals.js+++ b/packages/internal/transformers/markdown-literals.js@@ -1,23 +1,26 @@const ts = require('typescript');const path = require('path');const fs = require('fs');-const marked = require('marked');+const {Marked} = require('marked');+const {markedHighlight} = require('marked-highlight');+const highlightJs = require('highlight.js');-marked.setOptions({- headerIds: false,- highlight(code, lang) {- const highlightJs = require('highlight.js');- const language = highlightJs.getLanguage(lang) ? lang : 'plaintext';- return highlightJs.highlight(code, {language}).value;- },-});-marked.use({- renderer: {- link(href, title, text) {- return `<a href='${href}' target='_blank'>${text}</a>`;+const marked = new Marked(+ {+ renderer: {+ link(href, title, text) {+ return `<a href='${href}' target='_blank'>${text}</a>`;+ },},},-});+ markedHighlight({+ highlight(code, lang) {+ console.log(code);+ const language = highlightJs.getLanguage(lang) ? lang : 'plaintext';+ return highlightJs.highlight(code, {language}).value;+ },+ }),+);const transformerProgram = program => context => sourceFile => {const sourceMap = new Map();