Skip to content

Commit

Permalink
Fix replace-delimiters.sh, should fix spacicng errors
Browse files Browse the repository at this point in the history
  • Loading branch information
victorliu5296 committed Sep 5, 2024
1 parent f2842f6 commit 7f925c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source/public/
13 changes: 4 additions & 9 deletions replace-delimiters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ cd source/content/posts || exit
replace_delimiters() {
local file="$1"
perl -i -pe '
# Replace \( expression \) with $expression$ and remove spaces around the expression
s/\\\(\s*/\$/g;
s/\s*\\\)/\$/g;
# Remove any spaces between $ and the expression
s/\$\s+/\$/g;
s/\s+\$/\$/g;
# Replace \[ expression \] with ```math expression ```
s/\\\[\s*/```math /g;
s/\s*\\\]/ ```/g;
# Replace \( expression \) with $expression$ while preserving spaces
s/\\\(([^\)]*)\\\)/\$$1\$/g;
# Replace \[ expression \] with ```math expression ``` while preserving spaces
s/\\\[([^\]]*)\\\]/```math $1 ```/g;
' "$file"
}

Expand Down
2 changes: 2 additions & 0 deletions source/layouts/partials/helpers/katex.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
{ left: "$", right: "$", display: false },
{ left: "\\(", right: "\\)", display: false },
],
// ignoredTags: ["script", "noscript", "style", "textarea", "pre", "code", "option"],
// ignoredClasses: ["nokatex"],
});
});
</script>

0 comments on commit 7f925c8

Please sign in to comment.