Last active
February 11, 2021 16:58
-
-
Save vadimkantorov/0f4dce34cc9879958cdf1454be9ea921 to your computer and use it in GitHub Desktop.
A Bash function to strip %-style LaTeX comments. The script correctly treats escaped percents, and comments after double backslashes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# strip_latex_comments file.tex file.nocomments.tex | |
# strip_latex_comments_inplace file.tex | |
function strip_latex_comments {cat "$1" | '"sed 's/\([^\\]\|^\)\(\(\\\\\)*\)%.*/\1\2%/g' "'> "$2"; } | |
function strip_latex_comments_inplace {find . -name '*.tex' -exec sed -i'' 's/\([^\\]\|^\)\(\(\\\\\)*\)%.*/\1\2%/g' {} \; } | |
alias stip_latex_comments2="sed -e 's/\([^\\]\|^\)\(\(\\\\\)*\)%.*/\1\2%/g'" | |
# strip_latex_comments2 file.tex > file.nocomments.tex | |
function strip_latex_comments_inplace2 {sed -i'' -e 's/\([^\\]\|^\)\(\(\\\\\)*\)%.*/\1\2%/g' $(find $1 -name '*.tex') } | |
# strip_latex_comments_inplace2 mytexdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment