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

Added centered image and figure text option. #5

Open
wants to merge 1 commit 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
32 changes: 32 additions & 0 deletions jemdoc
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ def procfile(f):

infoblock = False
imgblock = False
imgcenterblock = False
tableblock = False
while 1: # wait for EOF.
p = pc(f)
Expand Down Expand Up @@ -1404,6 +1405,11 @@ def procfile(f):
imgblock = False
nl(f)
continue
elif imgcenterblock:
out(f.outf, '</center>\n</td></tr></table></center>\n')
imgcenterblock = False
nl(f)
continue
elif tableblock:
out(f.outf, '</td></tr></table>\n')
tableblock = False
Expand Down Expand Up @@ -1473,6 +1479,32 @@ def procfile(f):
out(f.outf, '&nbsp;</td>\n<td align="left">')
imgblock = True

elif len(g) >= 4 and g[1] == 'img_center':
# handles
# {}{img_center}{source}{alttext}{width}{height}{linktarget}.
g += ['']*(7 - len(g))

if g[4].isdigit():
g[4] += 'px'

if g[5].isdigit():
g[5] += 'px'

out(f.outf, '<center><table class="imgtable"><tr><td>\n')
if g[6]:
out(f.outf, '<a href="%s">' % g[6])
out(f.outf, '<img src="%s"' % g[2])
out(f.outf, ' alt="%s"' % g[3])
if g[4]:
out(f.outf, ' width="%s"' % g[4])
if g[5]:
out(f.outf, ' height="%s"' % g[5])
out(f.outf, ' />')
if g[6]:
out(f.outf, '</a>')
out(f.outf, '&nbsp;</td><tr/>\n<tr><td><center>')
imgcenterblock = True

else:
raise JandalError("couldn't handle block", f.linenum)

Expand Down
13 changes: 13 additions & 0 deletions www/extra.jemdoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ and alt text should be descriptive for reasons like
[http://en.wikipedia.org/wiki/Wikipedia:Alternative_text_for_images those given
by Wikipedia].

== Centered image blocks
It is likewise possible to use the following syntax, to obtain a
centered image with a figure text below.
~~~
{Centered image block syntax}{}
\~~~
\{}{img_center}{FILENAME.IMG}{alt text}{WIDTHpx}{HEIGHTpx}{IMGLINKTARGET}
Ordinary jemdoc markup goes here.
\~~~
~~~

Arguments follow the same rules as for left aligned image blocks.

== Raw blocks
When placing large amounts of raw html, you should use a raw block instead of
+\{\{inline html escaping\}\}+. As well as cleaner syntax, raw blocks will avoid
Expand Down