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

Cannot invoke to_hash_ast on a KramDown::Document instance #435

5t111111 opened this Issue May 28, 2017 · 3 comments


None yet
2 participants

5t111111 commented May 28, 2017

To convert Kramdown::Document to other formats, you can invoke implicitly defined methods (to_*) via method_missing implementation.

However, invoking to_hash_ast fails as hash_ast is camelize to HashAst under the hood, but there defines a class HashAST.

I think there are some possible solutions, but I am still not sure what is the best way to solve it:

  • Rename HashAST class to HashAst, but obviously it causes a breaking change
  • Define to_hash_ast explicitly, but it lacks consistency and DRY implmentation
  • Modify Kramdown::Utils.camelizeto support HasAST, but, umm it looks not good

I will consider to send a pull request If there's a solution you prefer.

@gettalong gettalong self-assigned this May 28, 2017


This comment has been minimized.


gettalong commented May 28, 2017

Thanks for opening the issue but the standard solution is to create the converter yourself and use it: Kramdown::Converter::HashAST.convert(@doc.root, @doc.options). The #to_* method are only there for convenience and were originally implemented so that kramdown provides the same interface as other libraries.

@gettalong gettalong closed this May 28, 2017


This comment has been minimized.


gettalong commented Jun 26, 2017

@5t111111 I have decided to alias HashAST to HashAst so that using to_hash_ast works. New release will be this week.


This comment has been minimized.


5t111111 commented Jun 27, 2017

@gettalong It is really appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment