Comments (2)
Wow! (after reading the sources)
>>> print LatexNodes2Text(keep_inline_math=True).latex_to_text(latex)
$γ$
>>> print LatexNodes2Text().latex_to_text(latex,keep_inline_math=True)
\gamma
>>> print LatexNodes2Text(keep_inline_math=True).latex_to_text(latex,keep_inline_math=True)
$\gamma$
from pylatexenc.
Hi, and thanks for noting this issue earlier. This behavior is indeed not at all intuitive and these options were very poorly designed. I am currently working on a new version pylatexenc 2.0 where both keep_inline_math
options for latexwalker
and latex2text
will be replaced by a single option math_mode=
in latex2text
. See updated doc here: https://pylatexenc.readthedocs.io/en/latest/latex2text/#pylatexenc.latex2text.LatexNodes2Text
E.g.:
>>> latex2text.LatexNodes2Text(math_mode='text').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If α=1 and β=2, then α+β=3'
>>> latex2text.LatexNodes2Text(math_mode='with-delimiters').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If $α=1$ and $β=2$, then $α+β=3$'
>>> latex2text.LatexNodes2Text(math_mode='verbatim').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If $\\alpha=1$ and $\\beta=2$, then $\\alpha+\\beta=3$'
I'd be happy to hear if you have any feedback.
from pylatexenc.
Related Issues (20)
- Argument parsers should be given the name of the encountered macro, in order to handle unknown macros HOT 3
- convert ₀:$_0$ ... ₉:$_9$ HOT 2
- Special characters treated as macros HOT 1
- Parsing commands containing "@" HOT 4
- parse LaTeX, replace $$ HOT 4
- Support for Python 3.7+
- various upgrades HOT 1
- how to instantiate LatexMacroNode? HOT 3
- suggestion for simpler/more correct MacroArgs
- nodelist_to_latex() doesn't respect node.environmentname HOT 1
- how to parse `\vrule height 2pt depth -1.6pt width 23pt` HOT 1
- how to parse `\def\enorm#1{\|#1\|_2}` HOT 1
- how to parse `\lstinline|code|` HOT 1
- macroname='SS' incorrectly translated HOT 1
- parse issue with `\newcommand{\be}{\begin{equation}}` HOT 3
- adapt LatexWalker context while walking HOT 1
- Input and output differs when converting a nodelist back into latex HOT 1
- Incorrect (?) parsing of content in `lstlisting` environment HOT 3
- Deprecation warning upon installation via pip HOT 1
- Any ideas to skip specific element in LatexWalker? HOT 1
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 pylatexenc.