From c040474fe0fb25d9cb9ff187990e33fb47b3a599 Mon Sep 17 00:00:00 2001 From: Alexandre Felipe Date: Thu, 8 Sep 2022 16:15:45 +0100 Subject: [PATCH] Embed SVG images in the readme. --- .gitignore | 1 + package.json | 4 +-- scripts/freeze-readme.js | 63 +++++++++++++++++++++++++++------------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index bef724c..9af76b1 100644 --- a/.gitignore +++ b/.gitignore @@ -146,3 +146,4 @@ src/index.js src/index.js.map src/text-renderer.d.ts src/text-renderer.js.map +static/frozen-* diff --git a/package.json b/package.json index a06855c..e4dd6c2 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,12 @@ "name": "@datadocs/formatter", "license": "MIT", "author": "Alexandre Felipe ", - "version": "0.1.4", + "version": "0.1.5", "private": false, "main": "dist/index.js", "files": [ "dist/index.js", - "src/index.d.ts", + "src/*.d.ts", "static/frozen-*.svg", "static/frozen-*.png" ], diff --git a/scripts/freeze-readme.js b/scripts/freeze-readme.js index ab85995..567a2a4 100644 --- a/scripts/freeze-readme.js +++ b/scripts/freeze-readme.js @@ -2,32 +2,55 @@ const fs = require('fs'); const https = require('https'); const readme_file = __dirname + '/../README.md' let README = fs.readFileSync(readme_file, {encoding:'utf-8'}) -let FROZEN_SECTION = /\<\!--\s*BEGIN\s*FROZEN\s*IMAGE\s*(https:\/\/\S*?)(?:\s*as\s*(\S*?))?\s*-->.*?\.*?\ - + ![](static/frozen-${alias}) ` } + +function embedFrozenImage(_, img){ + if(img.toLowerCase().endsWith('.svg')){ + return fs.readFileSync(`${__dirname}/../${img}`, {encoding:'utf-8'}) + }else{ + return _; + } +}