Module: Asciidoctor::SyntaxHighlighter::DefaultFactory

Includes:
Factory
Included in:
Asciidoctor::SyntaxHighlighter, DefaultFactoryProxy
Defined in:
lib/asciidoctor/syntax_highlighter.rb

Constant Summary collapse

PROVIDED =
{
  'coderay' => %(#{__dir__}/syntax_highlighter/coderay),
  'prettify' => %(#{__dir__}/syntax_highlighter/prettify),
  'pygments' => %(#{__dir__}/syntax_highlighter/pygments),
  'rouge' => %(#{__dir__}/syntax_highlighter/rouge),
}

Instance Method Summary collapse

Methods included from Factory

#create

Instance Method Details

#for(name) ⇒ Object

This method will lazy require and register additional built-in implementations, which include coderay, pygments, rouge, and prettify. Refer to Factory#for for parameters and return value.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/asciidoctor/syntax_highlighter.rb', line 190

def for name
  @@registry.fetch name do
    @@mutex.synchronize do
      @@registry.fetch name do
        if (require_path = PROVIDED[name])
          require require_path
          @@registry[name]
        else
          @@registry = @@registry.merge name => nil
          nil
        end
      end
    end
  end
end

#register(syntax_highlighter, *names) ⇒ Object



183
184
185
186
# File 'lib/asciidoctor/syntax_highlighter.rb', line 183

def register syntax_highlighter, *names
  @@mutex.owned? ? names.each {|name| @@registry = @@registry.merge name => syntax_highlighter } :
      @@mutex.synchronize { register syntax_highlighter, *names }
end