Comments (1)
Thanks Chris for the input.
The example in the README is supposed to highlight some of the changes blacktex does, but in general I think it's best to just try it out. Here's a list of test tuples (before/after), perhaps that'll already help you out:
# dollar replacement:
("a $a + b = c$ b", r"a \(a + b = c\) b"),
(r"a \$a + b = c\$ b", r"a \$a + b = c\$ b"),
(r"a \\$a + b = c\\$ b", "a \\\\\n\\(a + b = c\\\\\n\\) b"),
# text mods:
(r"{\em it's me!}", r"\emph{it's me!}"),
# comments:
("lorem %some comment \n %sit amet", "lorem "),
("% lorem some comment \n sit amet", "sit amet"),
("A % lorem some comment \n sit amet", "A sit amet"),
("{equation}%comment", "{equation}"),
# multiple comment lines:
("A\n%\n%\nB", "A\nB"),
# comment last:
("somemacro{%\nfoobar% \n}", "somemacro{foobar}"),
# trailing whitespace:
("lorem \n sit amet", "lorem\n sit amet"),
# obsolete text mod:
(r"lorem {\it ipsum dolor} sit amet", r"lorem \textit{ipsum dolor} sit amet"),
# multiple spaces:
("lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet"),
# It's allowed as indentation at the beginning of lines:
("a\n b\nc", "a\n b\nc"),
("\\[\n S(T)\\leq S(P_n).\n\\]\n", "\\[\n S(T)\\leq S(P_n).\n\\]\n"),
# spaces with brackets:
(r"( 1+2 ) { 3+4 } \left( 5+6 \right)", r"(1+2) {3+4} \left(5+6\right)"),
# multiple newlines:
("lorem \n\n\n\n\n\n ipsum dolor sit", "lorem\n\n\n ipsum dolor sit"),
# $$:
("a $$a + b = c$$ b", "a\n\\[\na + b = c\n\\]\nb"),
# whitespace after curly:
("\\textit{ \nlorem \n\n\n ipsum dol}", "\\textit{\nlorem\n\n\n ipsum dol}"),
# sub/superscript space:
("2^ng", "2^n g"),
("1/n^3", "1/n^3"),
("n^3", "n^3"),
("(n^3)", "(n^3)"),
("n^\\alpha", "n^\\alpha"),
("a^2_PP^2", "a^2_PP^2"),
# Underscore separation just produces too many false positives. Leave as is.
("2_ng", "2_ng"),
# dots:
("a,...,b", "a,\\dots,b"),
("a,\\cdots,b", "a,\\dots,b"),
# punctuation outside math:
("$a+b.$", "\\(a+b\\)."),
(".$a+b$", ".\\(a+b\\)"),
# <https://github.com/nschloe/blacktex/issues/43>
(r"$a$\,$b$", r"\(a\)\,\(b\)"),
# whitespace before punctuation:
("Some text .", "Some text."),
# nbsp before ref:
("text \\ref{something}", "text~\\ref{something}"),
# nbsp space:
("Some ~thing.", "Some thing."),
# double nbsp:
("Some~~text.", "Some\\quad text."),
# \over to \frac:
("a{b^{1+y} 2\\over 3^{4+x}}c", "a\\frac{b^{1+y} 2}{3^{4+x}}c"),
("{\\pi \\over4}", "\\frac{\\pi}{4}"),
# overline warn:
("\\overline", "\\overline"),
# linebreak after double backslash:
("T $2\\\\3 4\\\\\n6\\\\[2mm]7$.", "T \\(2\\\\\n3 4\\\\\n6\\\\\n[2mm]7\\)."),
# keywords without backslash:
(
"maximum and logarithm $max_x log(x)$",
r"maximum and logarithm \(\max_x \log(x)\)",
),
# def vs. newcommand
(r"\def\e{\text{r}}", r"\newcommand\e{\text{r}}"),
# linebreak around begin/end:
(
"A\\begin{equation}a+b\\end{equation} B \n\\begin{a}\nd+e\n\\end{a}\nB",
"A\n\\begin{equation}\na+b\n\\end{equation}\nB\n\\begin{a}\nd+e\n\\end{a}\nB",
),
# indentation is okay
(
"A\n \\begin{equation}\n a+b\n \\end{equation}",
"A\n \\begin{equation}\n a+b\n \\end{equation}",
),
# centerline:
("\\centerline{foobar}", "{\\centering foobar}"),
# eqnarray align:
(
"A\\begin{eqnarray*}a+b\\end{eqnarray*}F",
"A\n\\begin{align*}\na+b\n\\end{align*}\nF",
),
# env label:
(
"A\n\\begin{lemma}\n\\label{lvalpp}\\end{lemma}",
"A\n\\begin{lemma}\\label{lvalpp}\n\\end{lemma}",
),
("A\n\\section{Intro}\n\\label{lvalpp}", "A\n\\section{Intro}\\label{lvalpp}"),
(
"A\n\\subsection{Intro}\n\\label{lvalpp}",
"A\n\\subsection{Intro}\\label{lvalpp}",
),
# coloneqq
("A:=b+c", "A\\coloneqq b+c"),
("A := b+c", "A \\coloneqq b+c"),
("A : = b+c", "A \\coloneqq b+c"),
("b+c = : A", "b+c \\eqqcolon A"),
# tabular column spec:
(
"\\begin{tabular} \n {ccc}\ncontent\\end{tabular}",
"\\begin{tabular}{ccc}\ncontent\n\\end{tabular}",
),
# env option spec:
("\\begin{table} \n [h!]G\\end{table}", "\\begin{table}[h!]\nG\n\\end{table}"),
("\\begin{table} [h!]G\\end{table}", "\\begin{table}[h!]\nG\n\\end{table}"),
("\\begin{table} [h!]\nG\\end{table}", "\\begin{table}[h!]\nG\n\\end{table}"),
("\\begin{table} \n [h!]G\\end{table}", "\\begin{table}[h!]\nG\n\\end{table}"),
(
"\\begin{table} \n [h!]\\label{foo}\\end{table}",
"\\begin{table}[h!]\\label{foo}\n\\end{table}",
),
(
"\\begin{table} \n [h!]\\label{foo}\nG\\end{table}",
"\\begin{table}[h!]\\label{foo}\nG\n\\end{table}",
),
# space around operators:
("a+b=c", "a+b = c"),
("a+b&=&c", "a+b &=& c"),
# SI percentage:
(r"20\% \SI{30}{\%}", r"\SI{20}{\%} \SI{30}{\%}"),
# escaped percentage sign:
(r"25\% gain", r"\SI{25}{\%} gain"),
# https://github.com/nschloe/blacktex/issues/46
(r"\rightline{\bf a}", r"\rightline{\textbf{a}}"),
from blacktex.
Related Issues (20)
- Spaces sometimes inserted two characters after underscore in label HOT 3
- Comments should not be removed
- Is it possible to support support files in sub-folders? HOT 6
- Replace in-place HOT 1
- replace $ ... $ with \( .... \) HOT 2
- connection with black formatter HOT 1
- log is changed to \log in text mode HOT 1
- Blacktex dangerously reformats commented-out code even with `--keep-comments` option HOT 4
- Do not change \def HOT 7
- spacing command \, switches opening and closing parentheses
- blacktex produces error on spacing before $ HOT 1
- missing braces inside braces
- Removes spaces in \text environment HOT 4
- Line Breaking HOT 2
- Add a `conda` install option to `blacktex` HOT 2
- Exit code HOT 4
- IndexError HOT 3
- Source code no longer available in git? HOT 1
- Enter new license key for texworld HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blacktex.