Skip to content

Commit d1f72b4

Browse files
committed
build: swap out equations when publishing to npm
1 parent 2226dae commit d1f72b4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,10 @@ function publish( pkg, clbk ) {
11601160
}
11611161
}
11621162

1163+
// Replace GitHub MathJax equations with SVGs:
1164+
shell( 'find '+dist+' -type f -name \'*.md\' -print0 | xargs -0 perl -0777 -i -pe "s/```math\\n([\\s\\S]+?)\\n```\\n\\n//g"' );
1165+
shell( 'find '+dist+' -type f -name \'*.md\' -print0 | xargs -0 perl -0777 -i -pe "s/<!-- <div class=\\"equation\\"(.*)(<\\/div>\\s*-->)/<div class=\\"equation\\"$1<\\/div>/sg"' );
1166+
11631167
// Replace GitHub links to individual packages with npm links:
11641168
shell( 'find '+dist+' -type f -name \'*.md\' -print0 | xargs -0 sed -Ei \'/tree\\/main/b; s/@stdlib\\/([^:]*)\\]: https:\\/\\/github.com\\/stdlib-js/@stdlib\\/\\1\\]: https:\\/\\/www.npmjs.com\\/package\\/@stdlib/g\'' );
11651169

lib/node_modules/@stdlib/_tools/scripts/templates/workflow_publish.yml.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ jobs:
149149
# Add link definition for CLI package to README.md:
150150
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"links\">/<section class=\"links\">\n\n[$escapedPkg]: https:\/\/www.npmjs.com\/package\/$escapedPkg/"
151151

152+
# Replace GitHub MathJax equations with SVGs:
153+
- name: 'Replace GitHub MathJax equations with SVGs'
154+
run: |
155+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g'
156+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/<!-- <div class="equation"(.*)(<\/div>\s*-->)/<div class="equation"$1<\/div>/sg'
157+
152158
# Replace GitHub links to individual packages with npm links:
153159
- name: 'Replace all GitHub links to individual packages with npm links'
154160
run: |

lib/node_modules/@stdlib/_tools/scripts/templates/workflow_publish_cli.yml.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ jobs:
103103
SLUG=${{ github.repository }}
104104
git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" --follow-tags
105105

106+
# Replace GitHub MathJax equations with SVGs:
107+
- name: 'Replace GitHub MathJax equations with SVGs'
108+
run: |
109+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g'
110+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/<!-- <div class="equation"(.*)(<\/div>\s*-->)/<div class="equation"$1<\/div>/sg'
111+
106112
# Replace GitHub links to individual packages with npm links:
107113
- name: 'Replace all GitHub links to individual packages with npm links'
108114
run: |

0 commit comments

Comments
 (0)