summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-07-21 04:15:45 -0600
committerDan Allen <dan.j.allen@gmail.com>2021-07-21 04:16:17 -0600
commit77e46719294323ef50fa802a893d27ee2f3e065d (patch)
tree13c4d4b09da2d43ec71c4803069998ed1edfb598
parentb9b75b2d0b9991f6d8b32fbed2dd5d7235ff79c7 (diff)
patch Prawn to preserve leading null character when running on Ruby 3
-rw-r--r--lib/asciidoctor/pdf/ext/prawn.rb1
-rw-r--r--lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb15
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/asciidoctor/pdf/ext/prawn.rb b/lib/asciidoctor/pdf/ext/prawn.rb
index 8f01dc1f..b1f3540e 100644
--- a/lib/asciidoctor/pdf/ext/prawn.rb
+++ b/lib/asciidoctor/pdf/ext/prawn.rb
@@ -4,6 +4,7 @@
require_relative 'prawn/font_metric_cache'
require_relative 'prawn/font/afm'
require_relative 'prawn/images'
+require_relative 'prawn/formatted_text/arranger'
require_relative 'prawn/formatted_text/box'
require_relative 'prawn/formatted_text/fragment'
require_relative 'prawn/extensions'
diff --git a/lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb b/lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb
new file mode 100644
index 00000000..7d613985
--- /dev/null
+++ b/lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+Prawn::Text::Formatted::Arranger.prepend (Module.new do
+ def initialize *_args
+ super
+ @dummy_text = ?\u0000
+ end
+
+ def next_string
+ if (string = super) == @dummy_text
+ def string.lstrip!; end
+ end
+ string
+ end
+end)