Skip to content

Update AsciidocRenderer to account for dialects #10

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

Open
wants to merge 1 commit into
base: latex
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/asciidoctor/doctest/asciidoc_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module DocTest
# preset and validate some common parameters.
class AsciidocRenderer

attr_reader :backend_name, :converter, :template_dirs
attr_reader :backend_name, :converter, :template_dirs, :dialect

##
# @param backend_name [#to_s, nil] the name of the tested backend.
Expand All @@ -33,15 +33,19 @@ class AsciidocRenderer
# it's inappropriate for testing of custom backends, it's disabled
# by default.
#
# @param dialect = asciidoc, manuscript, or latex. Reference in
# `latex_test.rb` like this: `converter_opts backend_name: 'latex', dialect: 'latex'`
#
# @raise [ArgumentError] if some path from the +template_dirs+ doesn't
# exist or is not a directory.
#
def initialize(backend_name: nil, converter: nil, template_dirs: [],
templates_fallback: false)
templates_fallback: false, dialect: nil)

@backend_name = backend_name.to_s.freeze.presence
@converter = converter
@converter ||= NoFallbackTemplateConverter unless template_dirs.empty? || templates_fallback
@dialect = dialect

template_dirs = Array(template_dirs).freeze
template_dirs.each do |path|
Expand All @@ -63,6 +67,7 @@ def convert(text, opts = {})
safe: :safe,
backend: backend_name,
converter: converter,
'dialect' => dialect,
template_dirs: template_dirs
}.merge(opts)

Expand Down