jgm/pandoc

Suggestion: MS writer, preserve image name

Open

#4,475 opened on 2018年3月19日

GitHub で見る
 (10 comments) (0 reactions) (0 assignees)Haskell (44,133 stars) (3,850 forks)batch import
format:MSgood first issuewriter

説明

Currently (pandoc 2.1.2), pandoc's ms writer drops the complete image from the source

![DESCRIPTION](images/image) 

becomes

[IMAGE: DESCRIPTION]

But it seems to become so useful that I would suggest to make the file name available somehow; that way, one can make use of it when working with the ms document, and get a nice PS/PDF out of it. The following would be very unobtrusive markup-wise:

.PSPIC "images/name" WIDTH HEIGHT
[IMAGE: DESCRIPTION]

(Only provide WIDTH and HEIGHT if defined in the original document in useful units. Potentially comment them if they are percent values or other useless values.) This would even work if images/name is an EPS graphic and the file is processed with -Tps, but not give a nice caption. Else, it would be easily replaced by .PDFPIC "images/name" WIDTH HEIGHT, if one cares to do so. If the resulting error messages are too annoying, or you want to come closer to the LaTeX approach, one could consider the following; this way, tweaking the output to a real figure would be rather simple, and would show a real placeholder.

.KF \" start keep - non-floating with KS
.DS C \" center display
.ANYPIC  "images/name" WIDTH HEIGHT \"   replace this by a call to .PSPIC/.PDFPIC
.CAPTION "[DESCRIPTION 1]"
.DE \" end display
.KE \" end keep

(Only provide WIDTH and HEIGHT if defined in the original document in useful units. Potentially comment them if they are percent values or other useless values.) and e.g. include in the standard template as a dummy definition:

.de ANYPIC  \" macro to be replaced by user with PSPIC or PDFPIC
\\fC\\$1\\fP
.br
..
.nr IMAGE 0 1 \" register for image number, autoincrement
.de CAPTION
\v'1v'
.\"  nr IMAGE +1
Figure \\n+[IMAGE]. \\fB\\$1\\fP
..

For the term figure, you could rely on the groff localisation efforts (\*[locale]-lifg), but that may be to advanced as you would also have to mso <LANG>.tmac, which only exists for some languages.

コントリビューターガイド