Skip to content

Commit

Permalink
removed unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg-pb committed Feb 11, 2017
1 parent 3771296 commit c2981d0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
4 changes: 2 additions & 2 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Fixed
- Allow mappers of `~.dumps_list` to return a `~.LatexObject`.
- Section numbering default behaviour fixed
- Setter method for `~.LatexObject.escape` property added
- Escape and raw flags to `.Math` container
- Escape flag to `.Math` container
- ``_star_latex_name`` attribute of `.LatexObject` to append a star
- `.Alignat` environment that can contain strings and `.Math` containers
- `.Alignat` math environment

1.1.1_ - `docs <../v1.1.1/>`__ - 2016-12-10
-------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions examples/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
doc.append(Math(data=[Matrix(M), Matrix(a), '=', Matrix(M * a)]))

with doc.create(Subsection('Alignat math environment')):
with doc.create(Alignat(numbering=False)) as agn:
agn.add_math(r'\frac{a}{b} &= 0 \\')
agn.add_math([Matrix(M), Matrix(a), '&=', Matrix(M * a)])
with doc.create(Alignat(numbering=False, escape=False)) as agn:
agn.append(r'\frac{a}{b} &= 0 \\')
agn.extend([Matrix(M), Matrix(a), '&=', Matrix(M * a)])

with doc.create(Subsection('Beautiful graphs')):
with doc.create(TikZ()):
Expand Down
3 changes: 1 addition & 2 deletions pylatex/base_classes/latex_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ def latex_name(self):
star = ('*' if self._star_latex_name else '')
if self._latex_name is not None:
return self._latex_name + star
else:
return self.__class__.__name__.lower() + star
return self.__class__.__name__.lower() + star

@latex_name.setter
def latex_name(self, value):
Expand Down
34 changes: 5 additions & 29 deletions pylatex/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Alignat(Environment):
omit_if_empty = True
packages = [Package('amsmath')]

def __init__(self, aligns=2, numbering=True, escape=False):
def __init__(self, aligns=2, numbering=True, escape=True):
"""
Parameters
----------
Expand All @@ -34,24 +34,7 @@ def __init__(self, aligns=2, numbering=True, escape=False):
self.escape = escape
if not numbering:
self._star_latex_name = True
super().__init__(
start_arguments=[str(int(aligns))]
)

def add_math(self, data, **kwargs):
"""Add math to the list.
Args
----
data: str, `~.LatexObject`, list[str, `~.LatexObject`]
The equation itself.
kwargs : dict
any keyword arguments to Math container
"""
escape = kwargs.pop('escape', None) or self.escape
if not isinstance(data, (list, tuple)):
data = [data]
self.append(Math(data=list(data), raw=True, escape=escape, **kwargs))
super().__init__(start_arguments=[str(int(aligns))])


class Math(Container):
Expand All @@ -61,23 +44,19 @@ class Math(Container):

content_separator = ' '

def __init__(self, *, inline=False, data=None, raw=False,
escape=False):
def __init__(self, *, inline=False, data=None, escape=True):
r"""
Args
----
data: list
Content of the math container.
inline: bool
If the math should be displayed inline or not.
raw : bool
if raw, then will not be wrapped into environment
escape : bool
if True, will escape strings
"""

self.inline = inline
self.raw = raw
self.escape = escape
super().__init__(data=data)

Expand All @@ -89,12 +68,9 @@ def dumps(self):
str
"""
if self.raw:
return self.dumps_content()
elif self.inline:
if self.inline:
return '$' + self.dumps_content() + '$'
else:
return '\\[%\n' + self.dumps_content() + '%\n\\]'
return '\\[%\n' + self.dumps_content() + '%\n\\]'


class VectorName(Command):
Expand Down

0 comments on commit c2981d0

Please sign in to comment.