From 03a91e8e01ada62397c47161149a4ba203566563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20N=C3=B8rgaard?= Date: Wed, 12 Feb 2014 22:54:06 +0100 Subject: [PATCH] Added centered image and figure text option. --- jemdoc | 32 ++++++++++++++++++++++++++++++++ www/extra.jemdoc | 13 +++++++++++++ 2 files changed, 45 insertions(+) diff --git a/jemdoc b/jemdoc index 0e3e25e..c95d471 100755 --- a/jemdoc +++ b/jemdoc @@ -1342,6 +1342,7 @@ def procfile(f): infoblock = False imgblock = False + imgcenterblock = False tableblock = False while 1: # wait for EOF. p = pc(f) @@ -1404,6 +1405,11 @@ def procfile(f): imgblock = False nl(f) continue + elif imgcenterblock: + out(f.outf, '\n\n') + imgcenterblock = False + nl(f) + continue elif tableblock: out(f.outf, '\n') tableblock = False @@ -1473,6 +1479,32 @@ def procfile(f): out(f.outf, ' \n') 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, '
\n
\n') + if g[6]: + out(f.outf, '' % g[6]) + out(f.outf, '%s') + if g[6]: + out(f.outf, '') + out(f.outf, ' 
') + imgcenterblock = True + else: raise JandalError("couldn't handle block", f.linenum) diff --git a/www/extra.jemdoc b/www/extra.jemdoc index 49e6b9a..e694346 100644 --- a/www/extra.jemdoc +++ b/www/extra.jemdoc @@ -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