Coder Social home page Coder Social logo

Comments (4)

gettalong avatar gettalong commented on July 26, 2024

The code in Kramdown::Document.new does the following to get the parser:

      if Parser.const_defined?(parser)
        @root, @warnings = Parser.const_get(parser).parse(source, @options)
      else
        raise Kramdown::Error.new("kramdown has no parser to handle the specified input format: #{options[:input]}")
      end

Since the built-in parsers are only loaded on demand using autoload you may experience the problem because of multi-threading. I have had these problems with autoload, multi-threading and Rails in a different context where Rails was creating the problems. The only solution I could find was to pre-load the needed constants by either referencing them or require-ing the file they are defined in.

from kramdown.

jc00ke avatar jc00ke commented on July 26, 2024

Unfortunately options[:input] is nil or empty.

(Kramdown::Error) "kramdown has no parser to handle the specified input format: "

Curious as to why you autoload the parsers?

from kramdown.

gettalong avatar gettalong commented on July 26, 2024

options[:input] being nil is okay because then the default parser, kramdown, will be used. However, if it is empty, ie. "" kramdown will try to load a class without a name which is not possible. So you have to make sure that you either pass a valid kramdown parser name or nil in options[:input].

As for using autoload: This is the easiest way to ensure that the classes are available when referenced and avoid loading all parsers/converters at startup.

from kramdown.

jc00ke avatar jc00ke commented on July 26, 2024

Cool, thanks for the followup. I ended up just requiring all the parsers, which in my case isn't a big deal.

# config/initializers/kramdown.rb
require 'kramdown/parser/base'
require 'kramdown/parser/kramdown'
require 'kramdown/parser/html'
require 'kramdown/parser/markdown'

from kramdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.