Module | RedCloth::Formatters::LATEX |
In: |
lib/redcloth/formatters/latex.rb
lib/redcloth/formatters/latex.rb |
ENTITIES | = | YAML::load(File.read(File.dirname(__FILE__)+'/latex_entities.yml')) |
ENTITIES | = | YAML::load(File.read(File.dirname(__FILE__)+'/latex_entities.yml')) |
# File lib/redcloth/formatters/latex.rb, line 201 201: def arrow(opts) 202: "\\rightarrow{}" 203: end
# File lib/redcloth/formatters/latex.rb, line 201 201: def arrow(opts) 202: "\\rightarrow{}" 203: end
# File lib/redcloth/formatters/latex.rb, line 130 130: def bc_close(opts) 131: end_chunk("verbatim") + "\n" 132: end
# File lib/redcloth/formatters/latex.rb, line 130 130: def bc_close(opts) 131: end_chunk("verbatim") + "\n" 132: end
# File lib/redcloth/formatters/latex.rb, line 125 125: def bc_open(opts) 126: opts[:block] = true 127: begin_chunk("verbatim") + "\n" 128: end
# File lib/redcloth/formatters/latex.rb, line 125 125: def bc_open(opts) 126: opts[:block] = true 127: begin_chunk("verbatim") + "\n" 128: end
# File lib/redcloth/formatters/latex.rb, line 139 139: def bq_close(opts) 140: "\\end{quotation}\n\n" 141: end
# File lib/redcloth/formatters/latex.rb, line 139 139: def bq_close(opts) 140: "\\end{quotation}\n\n" 141: end
# File lib/redcloth/formatters/latex.rb, line 134 134: def bq_open(opts) 135: opts[:block] = true 136: "\\begin{quotation}\n" 137: end
# File lib/redcloth/formatters/latex.rb, line 134 134: def bq_open(opts) 135: opts[:block] = true 136: "\\begin{quotation}\n" 137: end
# File lib/redcloth/formatters/latex.rb, line 213 213: def copyright(opts) 214: "\\copyright{}" 215: end
# File lib/redcloth/formatters/latex.rb, line 213 213: def copyright(opts) 214: "\\copyright{}" 215: end
# File lib/redcloth/formatters/latex.rb, line 224 224: def dim(opts) 225: space = opts[:space] ? " " : '' 226: "#{opts[:text]}#{space}\\texttimes{}#{space}" 227: end
# File lib/redcloth/formatters/latex.rb, line 224 224: def dim(opts) 225: space = opts[:space] ? " " : '' 226: "#{opts[:text]}#{space}\\texttimes{}#{space}" 227: end
# File lib/redcloth/formatters/latex.rb, line 189 189: def ellipsis(opts) 190: "#{opts[:text]}\\ldots{}" 191: end
# File lib/redcloth/formatters/latex.rb, line 189 189: def ellipsis(opts) 190: "#{opts[:text]}\\ldots{}" 191: end
TODO: what do we do with (unknown) unicode entities ?
# File lib/redcloth/formatters/latex.rb, line 219 219: def entity(opts) 220: text = opts[:text][0..0] == '#' ? opts[:text][1..-1] : opts[:text] 221: ENTITIES[text] 222: end
TODO: what do we do with (unknown) unicode entities ?
# File lib/redcloth/formatters/latex.rb, line 219 219: def entity(opts) 220: text = opts[:text][0..0] == '#' ? opts[:text][1..-1] : opts[:text] 221: ENTITIES[text] 222: end
# File lib/redcloth/formatters/latex.rb, line 173 173: def fn(opts) 174: "\\footnotetext[#{opts[:id]}]{#{opts[:text]}}" 175: end
# File lib/redcloth/formatters/latex.rb, line 173 173: def fn(opts) 174: "\\footnotetext[#{opts[:id]}]{#{opts[:text]}}" 175: end
# File lib/redcloth/formatters/latex.rb, line 167 167: def footno(opts) 168: # TODO: insert a placeholder until we know the footnote content. 169: # For this to work, we need some kind of post-processing... 170: "\\footnotemark[#{opts[:text]}]" 171: end
# File lib/redcloth/formatters/latex.rb, line 167 167: def footno(opts) 168: # TODO: insert a placeholder until we know the footnote content. 169: # For this to work, we need some kind of post-processing... 170: "\\footnotemark[#{opts[:text]}]" 171: end
FIXME: use includegraphics with security verification
Remember to use ’\RequirePackage{graphicx}’ in your LaTeX header
FIXME: Look at dealing with width / height gracefully as this should be specified in a unit like cm rather than px.
# File lib/redcloth/formatters/latex.rb, line 153 153: def image(opts) 154: # Don't know how to use remote links, plus can we trust them? 155: return "" if opts[:src] =~ /^\w+\:\/\// 156: # Resolve CSS styles if any have been set 157: styling = opts[:class].to_s.split(/\s+/).collect { |style| latex_image_styles[style] }.compact.join ',' 158: # Build latex code 159: [ "\\begin{figure}[htp]", 160: " \\includegraphics[#{styling}]{#{opts[:src]}}", 161: (" \\caption{#{escape opts[:title]}}" if opts[:title]), 162: (" \\label{#{escape opts[:alt]}}" if opts[:alt]), 163: "\\end{figure}", 164: ].compact.join "\n" 165: end
FIXME: use includegraphics with security verification
Remember to use ’\RequirePackage{graphicx}’ in your LaTeX header
FIXME: Look at dealing with width / height gracefully as this should be specified in a unit like cm rather than px.
# File lib/redcloth/formatters/latex.rb, line 153 153: def image(opts) 154: # Don't know how to use remote links, plus can we trust them? 155: return "" if opts[:src] =~ /^\w+\:\/\// 156: # Resolve CSS styles if any have been set 157: styling = opts[:class].to_s.split(/\s+/).collect { |style| latex_image_styles[style] }.compact.join ',' 158: # Build latex code 159: [ "\\begin{figure}[htp]", 160: " \\includegraphics[#{styling}]{#{opts[:src]}}", 161: (" \\caption{#{escape opts[:title]}}" if opts[:title]), 162: (" \\label{#{escape opts[:alt]}}" if opts[:alt]), 163: "\\end{figure}", 164: ].compact.join "\n" 165: end
# File lib/redcloth/formatters/latex.rb, line 92 92: def li_open(opts) 93: "#{li_close unless opts.delete(:first)}\t\\item #{opts[:text]}" 94: end
# File lib/redcloth/formatters/latex.rb, line 92 92: def li_open(opts) 93: "#{li_close unless opts.delete(:first)}\t\\item #{opts[:text]}" 94: end
# File lib/redcloth/formatters/latex.rb, line 143 143: def link(opts) 144: "\\href{#{opts[:href]}}{#{opts[:name]}}" 145: end
# File lib/redcloth/formatters/latex.rb, line 143 143: def link(opts) 144: "\\href{#{opts[:href]}}{#{opts[:name]}}" 145: end
# File lib/redcloth/formatters/latex.rb, line 100 100: def p(opts) 101: opts[:text] + "\n\n" 102: end
# File lib/redcloth/formatters/latex.rb, line 100 100: def p(opts) 101: opts[:text] + "\n\n" 102: end
# File lib/redcloth/formatters/latex.rb, line 181 181: def quote1(opts) 182: "`#{opts[:text]}'" 183: end
# File lib/redcloth/formatters/latex.rb, line 181 181: def quote1(opts) 182: "`#{opts[:text]}'" 183: end
# File lib/redcloth/formatters/latex.rb, line 185 185: def quote2(opts) 186: "``#{opts[:text]}\"" 187: end
# File lib/redcloth/formatters/latex.rb, line 185 185: def quote2(opts) 186: "``#{opts[:text]}\"" 187: end
# File lib/redcloth/formatters/latex.rb, line 209 209: def registered(opts) 210: "\\textregistered{}" 211: end
# File lib/redcloth/formatters/latex.rb, line 209 209: def registered(opts) 210: "\\textregistered{}" 211: end
# File lib/redcloth/formatters/latex.rb, line 177 177: def snip(opts) 178: "\\begin{verbatim}#{opts[:text]}\\end{verbatim}" 179: end
# File lib/redcloth/formatters/latex.rb, line 177 177: def snip(opts) 178: "\\begin{verbatim}#{opts[:text]}\\end{verbatim}" 179: end
# File lib/redcloth/formatters/latex.rb, line 121 121: def table_close(opts) 122: "\t\\end{align*}\n" 123: end
# File lib/redcloth/formatters/latex.rb, line 121 121: def table_close(opts) 122: "\t\\end{align*}\n" 123: end
FIXME: we need to know the column count before opening tabular context.
# File lib/redcloth/formatters/latex.rb, line 117 117: def table_open(opts) 118: "\\begin{align*}\n" 119: end
FIXME: we need to know the column count before opening tabular context.
# File lib/redcloth/formatters/latex.rb, line 117 117: def table_open(opts) 118: "\\begin{align*}\n" 119: end
# File lib/redcloth/formatters/latex.rb, line 104 104: def td(opts) 105: "\t\t\t#{opts[:text]} &\n" 106: end
# File lib/redcloth/formatters/latex.rb, line 104 104: def td(opts) 105: "\t\t\t#{opts[:text]} &\n" 106: end
# File lib/redcloth/formatters/latex.rb, line 112 112: def tr_close(opts) 113: "\t\t\\\\\n" 114: end
# File lib/redcloth/formatters/latex.rb, line 112 112: def tr_close(opts) 113: "\t\t\\\\\n" 114: end
# File lib/redcloth/formatters/latex.rb, line 205 205: def trademark(opts) 206: "\\texttrademark{}" 207: end