Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

second optional argument for includegraphics #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions latex2edx/plastexit.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def filter_fix_displaymathverbatim(cls, m):
x = m.group(1).strip() # plastex2.1 - already escaped
return '[mathjax]%s[/mathjax]' % x.replace('\\end{edXmath}', '')

filter_fix_image_match = '<includegraphics style="(.*?)">(.*?)</includegraphics>'
filter_fix_image_match = '<includegraphics style="(.*?)" alt="(.*?)">(.*?)</includegraphics>'

def filter_fix_image(self, m):
width = 400
Expand Down Expand Up @@ -148,6 +148,12 @@ def filter_fix_image(self, m):
attribs = ';'.join(attribs)
if attribs:
attribs = 'style="' + attribs + '"'
alt = m.group(2)
if alt:
# Note for an empty alt text must have one single space
if alt == " ":
alt = ""
attribs = attribs + ' alt="' + alt + '"'

def make_image_html(fn,k,attribs):
self.imfnset.append(fn+k)
Expand All @@ -163,7 +169,7 @@ def make_image_html(fn,k,attribs):
src = self.imurl_fmt.format(imurl=self.imurl, fnbase=fnbase)
return '<img src="%s" width="%d" %s/>' % (src, width, attribs)

fnset = [m.group(2)]
fnset = [m.group(3)]
fnsuftab = ['','.png','.pdf','.png','.jpg']
for k in fnsuftab:
for fn in fnset:
Expand Down
2 changes: 1 addition & 1 deletion latex2edx/plastexpy/edXpsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class edXdiscussion(Base.Command):


class includegraphics(Base.Command):
args = '[ width ] self'
args = '[ width ] [ alt ] self'


class marginote(Base.Command): # tooltip margin note \marginote[options]{note}{anchor text}
Expand Down
2 changes: 1 addition & 1 deletion latex2edx/render/edXpsl.zpts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ name: edXdiscussion
<discussion tal:attributes='display_name self/attributes/display_name; attrib_string self/attributes/attrib_string' tal:content='self'></discussion>

name: includegraphics
<includegraphics tal:attributes="style string:${self/attributes/width}" tal:content='self'></includegraphics>
<includegraphics tal:attributes="style string:${self/attributes/width}; alt string:${self/attributes/alt}" tal:content='self'></includegraphics>

name: edXcite
<edxcite tal:attributes="ref string:${self/attributes/ref}" tal:content='self'></edxcite>
Expand Down