summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-05 03:27:47 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-09-05 03:27:47 -0600
commitaae57ce605d7e9a6704ef71a88591bbbf96db9c4 (patch)
treeef2745752f147715bbf263a79517e80246986902
parent9b8ce18ac42744ffa396ebb3064578f03a9ab43f (diff)
only load Treetop runtime so it does not overload require method
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/pdf/formatted_text.rb5
-rw-r--r--spec/formatted_text_spec.rb11
3 files changed, 13 insertions, 4 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index a880bbd5..ef6e8fe0 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -36,6 +36,7 @@ Bug Fixes::
* don't force justify first line of abstract if it ends with a hard break
* don't include children of section with empty title in TOC
* don't include children of section with empty title in outline
+* only load Treetop runtime so it does not overload `require` method
== 2.3.0 (2022-08-16) - @mojavelinux
diff --git a/lib/asciidoctor/pdf/formatted_text.rb b/lib/asciidoctor/pdf/formatted_text.rb
index 8fdd6468..15f0d97b 100644
--- a/lib/asciidoctor/pdf/formatted_text.rb
+++ b/lib/asciidoctor/pdf/formatted_text.rb
@@ -1,9 +1,6 @@
# frozen_string_literal: true
-require 'treetop'
-module Kernel
- alias require polyglot_original_require
-end if defined? polyglot_original_require
+require 'treetop/runtime'
require_relative 'formatted_text/parser'
require_relative 'formatted_text/transform'
require_relative 'formatted_text/formatter'
diff --git a/spec/formatted_text_spec.rb b/spec/formatted_text_spec.rb
new file mode 100644
index 00000000..73f30383
--- /dev/null
+++ b/spec/formatted_text_spec.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+require_relative 'spec_helper'
+
+describe Asciidoctor::PDF::FormattedText do
+ it 'should not wrap LoadError if require fails' do
+ (expect do
+ require 'no-such-gem'
+ end).to raise_exception LoadError, %r/no-such-gem/
+ end
+end