From c927640b4f1d97e6ecbc91ebb9bab159a1ac481f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 2 Apr 2019 09:00:35 +0200 Subject: emd2exml: Remove paragraphs around image tags Figure numbering will be messed up if an image tag is inside a paragraph. --- make/emd2exml.in | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/make/emd2exml.in b/make/emd2exml.in index cf53cec155..ec3de0a7f8 100755 --- a/make/emd2exml.in +++ b/make/emd2exml.in @@ -1238,7 +1238,7 @@ put_delayed(#state{out = Out} = S, Key, Data) -> S#state{out = [{delayed, Key, Data} | Out]}. put_chars(#state{out = Out} = S, Chars) -> - S#state{out = [[Chars] | Out]}. + S#state{out = [Chars | Out]}. put_line(#state{out = Out} = S, String) -> S#state{out = [[String, nl()] | Out]}. @@ -1278,9 +1278,27 @@ complete_output(S, [{delayed, Key, {image, _Text, Line}}|Rest], Out) -> {File, _} = S#state.ifile, error(File, Line, "Image definition name `~ts' not found~n", [Key]) end; +complete_output(S, [["

","\n"]=ParaStart, + Contents, + ["

","\n"]=ParaEnd|Rest], Out) -> + case is_image_tag(Contents) of + true -> + %% Get rid of the paragraph around an image tag. It would mess up + %% figure numbering. + complete_output(S, Rest, [Contents|Out]); + false -> + complete_output(S, [Contents,ParaEnd|Rest], [ParaStart|Out]) + end; complete_output(S, [Next|Rest], Out) -> complete_output(S, Rest, [Next|Out]). +is_image_tag(" + true; +is_image_tag([[_|_]=H | _]) -> + is_image_tag(H); +is_image_tag(_) -> + false. + write_output(_OFD, []) -> ok; write_output(OFD, [O|Os]) -> -- cgit v1.2.3