lib/polytexnic/preprocessors/polytex.rb
# Uses figures for images only when label is present.
# This allows users to put raw (centered) images in their documents.
# The default behavior of kramdown is to wrap such images in a figure
# environment, which causes LaTeX to (a) treat them as floats and (b)
# include a caption. This may not be what the user wants, and it's also
# nonstandard Markdown. On the other hand, it is really nice to be
# able to include captions using the default image syntax, so as a
# compromise we use Markdown behavior by default and kramdown behavior
# if the alt text contains a '\label' element.
Uses figures for images only when label is present.
This allows users to put raw (centered) images in their documents.
The default behavior of kramdown is to wrap such images in a figure
environment, which causes LaTeX to (a) treat them as floats and (b)
include a caption. This may not be what the user wants, and it's also
nonstandard Markdown. On the other hand, it is really nice to be
able to include captions using the default image syntax, so as a
compromise we use Markdown behavior by default and kramdown behavior
if the alt text contains a '\label' element.
Uses figures for images only when label is present . This allows users to put raw ( centered ) images in their documents . The default behavior of kramdown is to wrap such images in a figure environment which causes LaTeX to ( a ) treat them as floats and ( b ) include a caption . This may not be what the user wants and it ' s also nonstandard Markdown . On the other hand it is really nice to be able to include captions using the default image syntax so as a compromise we use Markdown behavior by default and kramdown behavior if the alt text contains a ' \ label ' element .
def convert_standalone_image(el, opts, img)
        alt_text = el.children.first.attr['alt']
        if has_label?(alt_text)
          attrs = attribute_list(el)
          "\\begin{figure}[H]#{attrs}\n\\begin{center}\n#{img}\n\\end{center}\n\\caption{#{escape(el.children.first.attr['alt'])}}\n#{latex_link_target(el, true)}\n\\end{figure}#{attrs}\n"
        else
          img.gsub('\includegraphics', '\image') + "\n"
        end
      end
def convert_standalone_image ( el , opts , img ) alt_text = el . children . first . attr [ 'alt' ] if has_label? ( alt_text ) attrs = attribute_list ( el ) "\\begin{figure}[H]#{attrs}\n\\begin{center}\n#{img}\n\\end{center}\n\\caption{#{escape(el.children.first.attr['alt'])}}\n#{latex_link_target(el, true)}\n\\end{figure}#{attrs}\n" else img . gsub ( '\includegraphics' , '\image' ) + "\n" end end
Uses figures for images only when label is present.
Uses figures for images only when label is present .
# Override the kramdown default by adding "here" placement. # Authors who want a different behavior can always use raw LaTeX.
el
opts
img