fletcher / peg-multimarkdown

An implementation of MultiMarkdown in C, using a PEG grammar - a fork of jgm's peg-markdown. No longer under active development - see MMD 5.
Other
523 stars 55 forks source link

Inline images converted to `begin{figure}...\end{figure}` blocks #27

Closed jcoulombe closed 13 years ago

jcoulombe commented 13 years ago
$ cat inlineFigure.txt 
This is a formatted ![image][] and a [link][] with attributes.

[image]: http://path.to/image "Image title" width=40px height=400px
[link]:  http://path.to/link.html "Some Link" class=external
         style="border: solid black 1px;"

$ cat inlineFigure.txt | multimarkdown -t latex
This is a formatted \begin{figure}
\begin{center}
\includegraphics[keepaspectratio,width=40pt,height=400pt]{http://path.to/image}
\end{center}
\caption[image]{Image title}
\label{image}
\end{figure}
 and a \href{http://path.to/link.html}{link}\footnote{\href{http://path.to/link.html}{http:\slash \slash path.to\slash link.html}} with attributes.
fletcher commented 13 years ago

This is how all images are handled in MMD. It would be time consuming, though not impossible, to separate out inline images vs those not in middle of a paragraph, but it seems that this would not happen very often. Plus, such an image would presumably not have a caption or other attributes, and it is probably easier to do:


Open to convincing arguments to the contrary, but otherwise I will this as an exercise for those who need it to customize their XSLT files.

jcoulombe commented 13 years ago

it is probably easier to do:

As long as you want to stick with only one output... Otherwise, I think it breaks the same source, multiple output feature, or becomes polluted with markup.

Plus, such an image would presumably not have a caption or other attributes

I admit that the example was bad, as it was taken literally from MMD syntax guide document without much thinking. But I was more thinking of something like:

Use the buttons ![left_arrow][] and ![right_arrow] to go back and forward.

[left_arrow]: left_arrow.png height=1cm
[right_arrow]: right_arrow.png height=1cm

As always, my own opinion...

fletcher commented 13 years ago

I think this is probably a rare enough occurrence to leave it as an add-on for those who need it. It would definitely be easier as an XSLT feature than in the parser itself.