Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add converter for block LaTeX #78

Closed
wants to merge 2 commits into from
Closed

Conversation

iyaja
Copy link

@iyaja iyaja commented Jan 15, 2020

This PR adds the ability to convert block LaTeX embedded in markdown files (delimited by $$ on both left and right sides) into a passthrough block with the latexmath macro. methods.co has an example.

This also prevents kramdoc from throwing an error when it sees $$..$$ in an input markdown file. Normally, this would result in the following error:

undefined method `convert_math' for #<Kramdown::AsciiDoc::Converter:0x00007fdc8f072c18> (NoMethodError)

@stallio
Copy link

stallio commented Jan 27, 2021

With the following adjustment, I was able to get this to work for inline LaTeX equations as well as blocks:

    def convert_math el, opts
      composed_text = el.value
      if el.options[:category] == :block
        mark_left = "\n[latexmath]\n++++\n"
        mark_right = "\n++++\n"
      else
        mark_left = "stem:["
        mark_right = "]"
      end
      opts[:writer].append %(#{mark_left}#{composed_text}#{mark_right})
    end

Note that the inline LaTeX must have $$ on both sides, rather than $, for this to work.

(Note also that I removed the \( and (\) delimiters because they didn't seem to be working for me.)

@mojavelinux
Copy link
Member

mojavelinux commented Jul 8, 2021

Resolved by cdcde0a with tests.

@mojavelinux mojavelinux closed this Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants