asciidoctor-pdf 1.5.0.alpha.16 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +12 -0
- data/CHANGELOG.adoc +415 -1
- data/LICENSE.adoc +1 -1
- data/NOTICE.adoc +14 -11
- data/README.adoc +647 -222
- data/asciidoctor-pdf.gemspec +47 -44
- data/bin/asciidoctor-pdf +5 -9
- data/bin/asciidoctor-pdf-optimize +20 -0
- data/data/fonts/ABOUT-mplus1mn-subset +26 -0
- data/data/fonts/ABOUT-mplus1p-subset +26 -0
- data/data/fonts/ABOUT-notoemoji-subset +3 -0
- data/data/fonts/ABOUT-notoserif-subset +26 -0
- data/data/fonts/{LICENSE-mplus-testflight-58 → LICENSE-mplus} +2 -2
- data/data/fonts/{LICENSE-noto-2015-06-05 → LICENSE-notoserif} +0 -0
- data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-bold-subset.ttf +0 -0
- data/data/fonts/mplus1mn-bold_italic-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-bold_italic-subset.ttf +0 -0
- data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-italic-subset.ttf +0 -0
- data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
- data/data/fonts/mplus1mn-regular-subset.ttf +0 -0
- data/data/fonts/mplus1p-regular-fallback.ttf +0 -0
- data/data/fonts/notoemoji-subset.ttf +0 -0
- data/data/fonts/notoserif-bold-subset.ttf +0 -0
- data/data/fonts/notoserif-bold_italic-subset.ttf +0 -0
- data/data/fonts/notoserif-italic-subset.ttf +0 -0
- data/data/fonts/notoserif-regular-subset.ttf +0 -0
- data/data/themes/base-theme.yml +26 -4
- data/data/themes/default-theme.yml +76 -60
- data/data/themes/default-with-fallback-font-theme.yml +9 -0
- data/docs/theming-guide.adoc +2731 -922
- data/lib/asciidoctor/pdf/converter.rb +4489 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_block.rb +7 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb +7 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/document.rb +5 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/image.rb +35 -0
- data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/list.rb +4 -2
- data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/list_item.rb +3 -1
- data/lib/asciidoctor/pdf/ext/asciidoctor/logging_shim.rb +33 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/section.rb +45 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor.rb +11 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/array.rb +6 -6
- data/lib/asciidoctor/pdf/ext/core/file.rb +9 -0
- data/lib/asciidoctor/pdf/ext/core/hash.rb +7 -0
- data/lib/asciidoctor/pdf/ext/core/numeric.rb +26 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/object.rb +3 -1
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/quantifiable_stdout.rb +9 -1
- data/lib/asciidoctor/pdf/ext/core/regexp.rb +5 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/string.rb +9 -13
- data/lib/asciidoctor/pdf/ext/core.rb +10 -0
- data/lib/asciidoctor/pdf/ext/pdf-core/page.rb +54 -0
- data/lib/asciidoctor/pdf/ext/pdf-core/pdf_object.rb +8 -0
- data/lib/asciidoctor/pdf/ext/pdf-core.rb +4 -0
- data/lib/asciidoctor/pdf/ext/prawn/coderay_encoder.rb +117 -0
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +922 -0
- data/lib/{asciidoctor-pdf/prawn_ext → asciidoctor/pdf/ext/prawn}/font/afm.rb +14 -10
- data/lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb +9 -0
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +66 -0
- data/lib/{asciidoctor-pdf/prawn_ext → asciidoctor/pdf/ext/prawn}/formatted_text/fragment.rb +21 -18
- data/lib/asciidoctor/pdf/ext/prawn/images.rb +54 -0
- data/lib/asciidoctor/pdf/ext/prawn-svg/interface.rb +14 -0
- data/lib/asciidoctor/pdf/ext/prawn-svg.rb +6 -0
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +76 -0
- data/lib/{asciidoctor-pdf/prawn-table_ext → asciidoctor/pdf/ext/prawn-table}/cell/text.rb +6 -3
- data/lib/asciidoctor/pdf/ext/prawn-table/cell.rb +60 -0
- data/lib/asciidoctor/pdf/ext/prawn-table.rb +6 -0
- data/lib/{asciidoctor-pdf/prawn-templates_ext.rb → asciidoctor/pdf/ext/prawn-templates.rb} +2 -0
- data/lib/asciidoctor/pdf/ext/prawn.rb +9 -0
- data/lib/asciidoctor/pdf/ext/pygments.rb +34 -0
- data/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb +208 -0
- data/lib/{asciidoctor-pdf/rouge_ext/themes/pastie.rb → asciidoctor/pdf/ext/rouge/themes/asciidoctor_pdf_default.rb} +7 -5
- data/lib/asciidoctor/pdf/ext/rouge.rb +5 -0
- data/lib/asciidoctor/pdf/ext.rb +9 -0
- data/lib/asciidoctor/pdf/formatted_text/formatter.rb +43 -0
- data/lib/asciidoctor/pdf/formatted_text/fragment_position_renderer.rb +14 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_destination_marker.rb +21 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb +134 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_image_renderer.rb +51 -0
- data/lib/asciidoctor/pdf/formatted_text/inline_text_aligner.rb +22 -0
- data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text/parser.rb +175 -53
- data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text/parser.treetop +20 -14
- data/lib/asciidoctor/pdf/formatted_text/source_wrap.rb +43 -0
- data/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb +55 -0
- data/lib/asciidoctor/pdf/formatted_text/transform.rb +394 -0
- data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text.rb +6 -0
- data/lib/asciidoctor/pdf/index_catalog.rb +133 -0
- data/lib/asciidoctor/pdf/measurements.rb +62 -0
- data/lib/asciidoctor/pdf/optimizer.rb +44 -0
- data/lib/asciidoctor/pdf/pdfmark.rb +41 -0
- data/lib/asciidoctor/pdf/roman_numeral.rb +128 -0
- data/lib/asciidoctor/pdf/sanitizer.rb +45 -0
- data/lib/asciidoctor/pdf/text_transformer.rb +116 -0
- data/lib/asciidoctor/pdf/theme_loader.rb +305 -0
- data/lib/asciidoctor/pdf/version.rb +8 -0
- data/lib/asciidoctor/pdf.rb +15 -0
- data/lib/asciidoctor-pdf/converter.rb +2 -3343
- data/lib/asciidoctor-pdf/version.rb +3 -5
- data/lib/asciidoctor-pdf.rb +3 -3
- metadata +242 -128
- data/Gemfile +0 -22
- data/Rakefile +0 -81
- data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +0 -24
- data/lib/asciidoctor-pdf/asciidoctor_ext/section.rb +0 -34
- data/lib/asciidoctor-pdf/asciidoctor_ext.rb +0 -5
- data/lib/asciidoctor-pdf/core_ext/numeric.rb +0 -15
- data/lib/asciidoctor-pdf/core_ext/ostruct.rb +0 -17
- data/lib/asciidoctor-pdf/core_ext.rb +0 -4
- data/lib/asciidoctor-pdf/formatted_text/formatter.rb +0 -27
- data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +0 -21
- data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +0 -172
- data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +0 -46
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +0 -261
- data/lib/asciidoctor-pdf/implicit_header_processor.rb +0 -63
- data/lib/asciidoctor-pdf/index_catalog.rb +0 -119
- data/lib/asciidoctor-pdf/measurements.rb +0 -58
- data/lib/asciidoctor-pdf/pdf-core_ext/page.rb +0 -25
- data/lib/asciidoctor-pdf/pdf-core_ext/pdf_object.rb +0 -6
- data/lib/asciidoctor-pdf/pdf-core_ext.rb +0 -2
- data/lib/asciidoctor-pdf/pdfmark.rb +0 -33
- data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +0 -10
- data/lib/asciidoctor-pdf/prawn-svg_ext.rb +0 -4
- data/lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb +0 -69
- data/lib/asciidoctor-pdf/prawn-table_ext.rb +0 -3
- data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +0 -115
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +0 -863
- data/lib/asciidoctor-pdf/prawn_ext/images.rb +0 -40
- data/lib/asciidoctor-pdf/prawn_ext.rb +0 -5
- data/lib/asciidoctor-pdf/roman_numeral.rb +0 -114
- data/lib/asciidoctor-pdf/rouge_ext/css_theme.rb +0 -15
- data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +0 -164
- data/lib/asciidoctor-pdf/rouge_ext.rb +0 -4
- data/lib/asciidoctor-pdf/sanitizer.rb +0 -88
- data/lib/asciidoctor-pdf/temporary_path.rb +0 -13
- data/lib/asciidoctor-pdf/theme_loader.rb +0 -247
- data/lib/asciidoctor-pdf/ttfunk_ext.rb +0 -8
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
# Autogenerated from a Treetop grammar. Edits may be lost.
|
3
3
|
|
4
4
|
|
5
5
|
module Asciidoctor
|
6
|
-
module
|
6
|
+
module PDF
|
7
7
|
module FormattedText
|
8
8
|
module Markup
|
9
9
|
include Treetop::Runtime
|
@@ -60,7 +60,7 @@ module Markup
|
|
60
60
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
61
61
|
r1 = r3
|
62
62
|
else
|
63
|
-
r4 =
|
63
|
+
r4 = _nt_charref
|
64
64
|
if r4
|
65
65
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
66
66
|
r1 = r4
|
@@ -356,44 +356,44 @@ module Markup
|
|
356
356
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
357
357
|
r0 = r1
|
358
358
|
else
|
359
|
-
if (match_len = has_terminal?('
|
359
|
+
if (match_len = has_terminal?('strong', false, index))
|
360
360
|
r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
361
361
|
@index += match_len
|
362
362
|
else
|
363
|
-
terminal_parse_failure('
|
363
|
+
terminal_parse_failure('strong')
|
364
364
|
r2 = nil
|
365
365
|
end
|
366
366
|
if r2
|
367
367
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
368
368
|
r0 = r2
|
369
369
|
else
|
370
|
-
if (match_len = has_terminal?('
|
370
|
+
if (match_len = has_terminal?('em', false, index))
|
371
371
|
r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
372
372
|
@index += match_len
|
373
373
|
else
|
374
|
-
terminal_parse_failure('
|
374
|
+
terminal_parse_failure('em')
|
375
375
|
r3 = nil
|
376
376
|
end
|
377
377
|
if r3
|
378
378
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
379
379
|
r0 = r3
|
380
380
|
else
|
381
|
-
if (match_len = has_terminal?('
|
381
|
+
if (match_len = has_terminal?('code', false, index))
|
382
382
|
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
383
383
|
@index += match_len
|
384
384
|
else
|
385
|
-
terminal_parse_failure('
|
385
|
+
terminal_parse_failure('code')
|
386
386
|
r4 = nil
|
387
387
|
end
|
388
388
|
if r4
|
389
389
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
390
390
|
r0 = r4
|
391
391
|
else
|
392
|
-
if (match_len = has_terminal?('
|
392
|
+
if (match_len = has_terminal?('color', false, index))
|
393
393
|
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
394
394
|
@index += match_len
|
395
395
|
else
|
396
|
-
terminal_parse_failure('
|
396
|
+
terminal_parse_failure('color')
|
397
397
|
r5 = nil
|
398
398
|
end
|
399
399
|
if r5
|
@@ -422,22 +422,22 @@ module Markup
|
|
422
422
|
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
423
423
|
r0 = r7
|
424
424
|
else
|
425
|
-
if (match_len = has_terminal?('
|
425
|
+
if (match_len = has_terminal?('button', false, index))
|
426
426
|
r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
427
427
|
@index += match_len
|
428
428
|
else
|
429
|
-
terminal_parse_failure('
|
429
|
+
terminal_parse_failure('button')
|
430
430
|
r8 = nil
|
431
431
|
end
|
432
432
|
if r8
|
433
433
|
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
434
434
|
r0 = r8
|
435
435
|
else
|
436
|
-
if (match_len = has_terminal?('
|
436
|
+
if (match_len = has_terminal?('key', false, index))
|
437
437
|
r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
438
438
|
@index += match_len
|
439
439
|
else
|
440
|
-
terminal_parse_failure('
|
440
|
+
terminal_parse_failure('key')
|
441
441
|
r9 = nil
|
442
442
|
end
|
443
443
|
if r9
|
@@ -455,8 +455,44 @@ module Markup
|
|
455
455
|
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
456
456
|
r0 = r10
|
457
457
|
else
|
458
|
-
|
459
|
-
|
458
|
+
if (match_len = has_terminal?('sub', false, index))
|
459
|
+
r11 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
460
|
+
@index += match_len
|
461
|
+
else
|
462
|
+
terminal_parse_failure('sub')
|
463
|
+
r11 = nil
|
464
|
+
end
|
465
|
+
if r11
|
466
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
467
|
+
r0 = r11
|
468
|
+
else
|
469
|
+
if (match_len = has_terminal?('mark', false, index))
|
470
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
471
|
+
@index += match_len
|
472
|
+
else
|
473
|
+
terminal_parse_failure('mark')
|
474
|
+
r12 = nil
|
475
|
+
end
|
476
|
+
if r12
|
477
|
+
r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
|
478
|
+
r0 = r12
|
479
|
+
else
|
480
|
+
if (match_len = has_terminal?('del', false, index))
|
481
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
482
|
+
@index += match_len
|
483
|
+
else
|
484
|
+
terminal_parse_failure('del')
|
485
|
+
r13 = nil
|
486
|
+
end
|
487
|
+
if r13
|
488
|
+
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
489
|
+
r0 = r13
|
490
|
+
else
|
491
|
+
@index = i0
|
492
|
+
r0 = nil
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
460
496
|
end
|
461
497
|
end
|
462
498
|
end
|
@@ -776,31 +812,39 @@ module Markup
|
|
776
812
|
r0
|
777
813
|
end
|
778
814
|
|
779
|
-
module
|
780
|
-
def
|
815
|
+
module Charref0
|
816
|
+
def character_decimal
|
781
817
|
elements[1]
|
782
818
|
end
|
783
819
|
end
|
784
820
|
|
785
|
-
module
|
821
|
+
module Charref1
|
822
|
+
def character_hex
|
823
|
+
elements[1]
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
module Charref2
|
786
828
|
end
|
787
829
|
|
788
|
-
module
|
830
|
+
module Charref3
|
789
831
|
def content
|
790
|
-
if (
|
791
|
-
{ type: :
|
832
|
+
if (ref_data = elements[1]).terminal?
|
833
|
+
{ type: :charref, reference_type: :name, value: ref_data.text_value.to_sym }
|
834
|
+
elsif ref_data.elements[0].text_value == '#'
|
835
|
+
{ type: :charref, reference_type: :decimal, value: ref_data.elements[1].text_value.to_i }
|
792
836
|
else
|
793
|
-
{ type: :
|
837
|
+
{ type: :charref, reference_type: :hex, value: ref_data.elements[1].text_value }
|
794
838
|
end
|
795
839
|
end
|
796
840
|
end
|
797
841
|
|
798
|
-
def
|
842
|
+
def _nt_charref
|
799
843
|
start_index = index
|
800
|
-
if node_cache[:
|
801
|
-
cached = node_cache[:
|
844
|
+
if node_cache[:charref].has_key?(index)
|
845
|
+
cached = node_cache[:charref][index]
|
802
846
|
if cached
|
803
|
-
node_cache[:
|
847
|
+
node_cache[:charref][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
804
848
|
@index = cached.interval.end
|
805
849
|
end
|
806
850
|
return cached
|
@@ -827,12 +871,12 @@ module Markup
|
|
827
871
|
end
|
828
872
|
s3 << r4
|
829
873
|
if r4
|
830
|
-
r5 =
|
874
|
+
r5 = _nt_character_decimal
|
831
875
|
s3 << r5
|
832
876
|
end
|
833
877
|
if s3.last
|
834
878
|
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
835
|
-
r3.extend(
|
879
|
+
r3.extend(Charref0)
|
836
880
|
else
|
837
881
|
@index = i3
|
838
882
|
r3 = nil
|
@@ -841,47 +885,72 @@ module Markup
|
|
841
885
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
842
886
|
r2 = r3
|
843
887
|
else
|
844
|
-
|
888
|
+
i6, s6 = index, []
|
889
|
+
if (match_len = has_terminal?('#x', false, index))
|
890
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
891
|
+
@index += match_len
|
892
|
+
else
|
893
|
+
terminal_parse_failure('#x')
|
894
|
+
r7 = nil
|
895
|
+
end
|
896
|
+
s6 << r7
|
897
|
+
if r7
|
898
|
+
r8 = _nt_character_hex
|
899
|
+
s6 << r8
|
900
|
+
end
|
901
|
+
if s6.last
|
902
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
903
|
+
r6.extend(Charref1)
|
904
|
+
else
|
905
|
+
@index = i6
|
906
|
+
r6 = nil
|
907
|
+
end
|
845
908
|
if r6
|
846
909
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
847
910
|
r2 = r6
|
848
911
|
else
|
849
|
-
|
850
|
-
|
912
|
+
r9 = _nt_character_name
|
913
|
+
if r9
|
914
|
+
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
915
|
+
r2 = r9
|
916
|
+
else
|
917
|
+
@index = i2
|
918
|
+
r2 = nil
|
919
|
+
end
|
851
920
|
end
|
852
921
|
end
|
853
922
|
s0 << r2
|
854
923
|
if r2
|
855
924
|
if (match_len = has_terminal?(';', false, index))
|
856
|
-
|
925
|
+
r10 = true
|
857
926
|
@index += match_len
|
858
927
|
else
|
859
928
|
terminal_parse_failure(';')
|
860
|
-
|
929
|
+
r10 = nil
|
861
930
|
end
|
862
|
-
s0 <<
|
931
|
+
s0 << r10
|
863
932
|
end
|
864
933
|
end
|
865
934
|
if s0.last
|
866
935
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
867
|
-
r0.extend(
|
868
|
-
r0.extend(
|
936
|
+
r0.extend(Charref2)
|
937
|
+
r0.extend(Charref3)
|
869
938
|
else
|
870
939
|
@index = i0
|
871
940
|
r0 = nil
|
872
941
|
end
|
873
942
|
|
874
|
-
node_cache[:
|
943
|
+
node_cache[:charref][start_index] = r0
|
875
944
|
|
876
945
|
r0
|
877
946
|
end
|
878
947
|
|
879
|
-
def
|
948
|
+
def _nt_character_decimal
|
880
949
|
start_index = index
|
881
|
-
if node_cache[:
|
882
|
-
cached = node_cache[:
|
950
|
+
if node_cache[:character_decimal].has_key?(index)
|
951
|
+
cached = node_cache[:character_decimal][index]
|
883
952
|
if cached
|
884
|
-
node_cache[:
|
953
|
+
node_cache[:character_decimal][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
885
954
|
@index = cached.interval.end
|
886
955
|
end
|
887
956
|
return cached
|
@@ -912,17 +981,58 @@ module Markup
|
|
912
981
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
913
982
|
end
|
914
983
|
|
915
|
-
node_cache[:
|
984
|
+
node_cache[:character_decimal][start_index] = r0
|
916
985
|
|
917
986
|
r0
|
918
987
|
end
|
919
988
|
|
920
|
-
def
|
989
|
+
def _nt_character_hex
|
921
990
|
start_index = index
|
922
|
-
if node_cache[:
|
923
|
-
cached = node_cache[:
|
991
|
+
if node_cache[:character_hex].has_key?(index)
|
992
|
+
cached = node_cache[:character_hex][index]
|
924
993
|
if cached
|
925
|
-
node_cache[:
|
994
|
+
node_cache[:character_hex][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
995
|
+
@index = cached.interval.end
|
996
|
+
end
|
997
|
+
return cached
|
998
|
+
end
|
999
|
+
|
1000
|
+
s0, i0 = [], index
|
1001
|
+
loop do
|
1002
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-f]'] ||= Regexp.new(gr), :regexp, index)
|
1003
|
+
r1 = true
|
1004
|
+
@index += 1
|
1005
|
+
else
|
1006
|
+
terminal_parse_failure('[0-9a-f]')
|
1007
|
+
r1 = nil
|
1008
|
+
end
|
1009
|
+
if r1
|
1010
|
+
s0 << r1
|
1011
|
+
else
|
1012
|
+
break
|
1013
|
+
end
|
1014
|
+
if s0.size == 5
|
1015
|
+
break
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
if s0.size < 2
|
1019
|
+
@index = i0
|
1020
|
+
r0 = nil
|
1021
|
+
else
|
1022
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
node_cache[:character_hex][start_index] = r0
|
1026
|
+
|
1027
|
+
r0
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
def _nt_character_name
|
1031
|
+
start_index = index
|
1032
|
+
if node_cache[:character_name].has_key?(index)
|
1033
|
+
cached = node_cache[:character_name][index]
|
1034
|
+
if cached
|
1035
|
+
node_cache[:character_name][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
926
1036
|
@index = cached.interval.end
|
927
1037
|
end
|
928
1038
|
return cached
|
@@ -973,26 +1083,38 @@ module Markup
|
|
973
1083
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
974
1084
|
r0 = r4
|
975
1085
|
else
|
976
|
-
if (match_len = has_terminal?('
|
1086
|
+
if (match_len = has_terminal?('nbsp', false, index))
|
977
1087
|
r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
978
1088
|
@index += match_len
|
979
1089
|
else
|
980
|
-
terminal_parse_failure('
|
1090
|
+
terminal_parse_failure('nbsp')
|
981
1091
|
r5 = nil
|
982
1092
|
end
|
983
1093
|
if r5
|
984
1094
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
985
1095
|
r0 = r5
|
986
1096
|
else
|
987
|
-
|
988
|
-
|
1097
|
+
if (match_len = has_terminal?('quot', false, index))
|
1098
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1099
|
+
@index += match_len
|
1100
|
+
else
|
1101
|
+
terminal_parse_failure('quot')
|
1102
|
+
r6 = nil
|
1103
|
+
end
|
1104
|
+
if r6
|
1105
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
1106
|
+
r0 = r6
|
1107
|
+
else
|
1108
|
+
@index = i0
|
1109
|
+
r0 = nil
|
1110
|
+
end
|
989
1111
|
end
|
990
1112
|
end
|
991
1113
|
end
|
992
1114
|
end
|
993
1115
|
end
|
994
1116
|
|
995
|
-
node_cache[:
|
1117
|
+
node_cache[:character_name][start_index] = r0
|
996
1118
|
|
997
1119
|
r0
|
998
1120
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
module Asciidoctor
|
3
|
-
module
|
3
|
+
module PDF
|
4
4
|
module FormattedText
|
5
5
|
grammar Markup
|
6
6
|
rule text
|
@@ -8,7 +8,7 @@ grammar Markup
|
|
8
8
|
end
|
9
9
|
|
10
10
|
rule complex
|
11
|
-
(cdata / element /
|
11
|
+
(cdata / element / charref)* {
|
12
12
|
def content
|
13
13
|
elements.map {|e| e.content }
|
14
14
|
end
|
@@ -49,9 +49,8 @@ grammar Markup
|
|
49
49
|
|
50
50
|
rule tag_name
|
51
51
|
# QUESTION faster to do regex?
|
52
|
-
# QUESTION
|
53
|
-
|
54
|
-
'a' / 'code' / 'color' / 'del' / 'em' / 'font' / 'span' / 'strong' / 'sub' / 'sup'
|
52
|
+
# QUESTION what about supporting hr?
|
53
|
+
'a' / 'strong' / 'em' / 'code' / 'color' / 'font' / 'span' / 'button' / 'key' / 'sup' / 'sub' / 'mark' / 'del'
|
55
54
|
end
|
56
55
|
|
57
56
|
rule void_tag_name
|
@@ -95,25 +94,32 @@ grammar Markup
|
|
95
94
|
}
|
96
95
|
end
|
97
96
|
|
98
|
-
rule
|
99
|
-
'&' ('#'
|
97
|
+
rule charref
|
98
|
+
'&' ('#' character_decimal / '#x' character_hex / character_name) ';' {
|
100
99
|
def content
|
101
|
-
if (
|
102
|
-
{ type: :
|
100
|
+
if (ref_data = elements[1]).terminal?
|
101
|
+
{ type: :charref, reference_type: :name, value: ref_data.text_value.to_sym }
|
102
|
+
elsif ref_data.elements[0].text_value == '#'
|
103
|
+
{ type: :charref, reference_type: :decimal, value: ref_data.elements[1].text_value.to_i }
|
103
104
|
else
|
104
|
-
{ type: :
|
105
|
+
{ type: :charref, reference_type: :hex, value: ref_data.elements[1].text_value }
|
105
106
|
end
|
106
107
|
end
|
107
108
|
}
|
108
109
|
end
|
109
110
|
|
110
|
-
rule
|
111
|
+
rule character_decimal
|
111
112
|
# NOTE 6 decimals only supported in Asciidoctor 1.5.5 and up
|
112
113
|
[0-9] 2..6
|
113
114
|
end
|
114
115
|
|
115
|
-
rule
|
116
|
-
|
116
|
+
rule character_hex
|
117
|
+
# NOTE 5 hexadecimals only supported in Asciidoctor 1.5.5 and up
|
118
|
+
[0-9a-f] 2..5
|
119
|
+
end
|
120
|
+
|
121
|
+
rule character_name
|
122
|
+
'amp' / 'apos' / 'gt' / 'lt' / 'nbsp' / 'quot'
|
117
123
|
end
|
118
124
|
|
119
125
|
rule spaces
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Asciidoctor
|
4
|
+
module PDF
|
5
|
+
module FormattedText
|
6
|
+
module SourceWrap
|
7
|
+
NoBreakSpace = ?\u00a0
|
8
|
+
|
9
|
+
def wrap array
|
10
|
+
initialize_wrap array
|
11
|
+
stop = nil
|
12
|
+
highlight_line = nil
|
13
|
+
unconsumed = @arranger.unconsumed
|
14
|
+
if (linenum_fragment = unconsumed[0] || {})[:linenum]
|
15
|
+
linenum_spacer = { text: NoBreakSpace + (' ' * (linenum_fragment[:text].length - 1)) }
|
16
|
+
end
|
17
|
+
until stop
|
18
|
+
if linenum_spacer && (first_fragment = unconsumed[0])
|
19
|
+
if first_fragment[:linenum]
|
20
|
+
highlight_line = (second_fragment = unconsumed[1]) && (second_fragment[:highlight]) ? second_fragment.dup : nil
|
21
|
+
else
|
22
|
+
first_fragment[:text] = first_fragment[:text].lstrip
|
23
|
+
@arranger.unconsumed.unshift highlight_line if highlight_line
|
24
|
+
@arranger.unconsumed.unshift linenum_spacer.dup
|
25
|
+
end
|
26
|
+
end
|
27
|
+
@line_wrap.wrap_line document: @document, kerning: @kerning, width: available_width, arranger: @arranger, disable_wrap_by_char: @disable_wrap_by_char
|
28
|
+
if enough_height_for_this_line?
|
29
|
+
move_baseline_down
|
30
|
+
print_line
|
31
|
+
else
|
32
|
+
stop = true
|
33
|
+
end
|
34
|
+
stop ||= @single_line || @arranger.finished?
|
35
|
+
end
|
36
|
+
@text = @printed_lines.join ?\n
|
37
|
+
@everything_printed = @arranger.finished?
|
38
|
+
@arranger.unconsumed
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Asciidoctor::Pdf::FormattedText
|
4
|
+
module TextBackgroundAndBorderRenderer
|
5
|
+
module_function
|
6
|
+
|
7
|
+
DummyText = ?\u0000
|
8
|
+
|
9
|
+
# render_behind is called before the text is printed
|
10
|
+
def render_behind fragment
|
11
|
+
return if (pdf = fragment.document).scratch?
|
12
|
+
data = fragment.format_state
|
13
|
+
if data[:inline_block]
|
14
|
+
padding = (height = fragment.line_height) - fragment.height
|
15
|
+
at = [fragment.left, fragment.top + padding * 0.5]
|
16
|
+
width = data[:extend] ? (pdf.bounds.width - fragment.left) : fragment.width
|
17
|
+
fragment.conceal if fragment.text == DummyText
|
18
|
+
elsif (border_offset = data[:border_offset])
|
19
|
+
at = [fragment.left, fragment.top + border_offset]
|
20
|
+
width = fragment.width
|
21
|
+
height = fragment.height + border_offset * 2
|
22
|
+
else
|
23
|
+
at = fragment.top_left
|
24
|
+
width = fragment.width
|
25
|
+
height = fragment.height
|
26
|
+
end
|
27
|
+
border_radius = data[:border_radius]
|
28
|
+
if (background_color = data[:background_color])
|
29
|
+
prev_fill_color = pdf.fill_color
|
30
|
+
pdf.fill_color background_color
|
31
|
+
if border_radius
|
32
|
+
pdf.fill_rounded_rectangle at, width, height, border_radius
|
33
|
+
else
|
34
|
+
pdf.fill_rectangle at, width, height
|
35
|
+
end
|
36
|
+
pdf.fill_color prev_fill_color
|
37
|
+
end
|
38
|
+
if (border_width = data[:border_width])
|
39
|
+
border_color = data[:border_color]
|
40
|
+
prev_stroke_color = pdf.stroke_color
|
41
|
+
prev_line_width = pdf.line_width
|
42
|
+
pdf.stroke_color border_color
|
43
|
+
pdf.line_width border_width
|
44
|
+
if border_radius
|
45
|
+
pdf.stroke_rounded_rectangle at, width, height, border_radius
|
46
|
+
else
|
47
|
+
pdf.stroke_rectangle at, width, height
|
48
|
+
end
|
49
|
+
pdf.stroke_color prev_stroke_color
|
50
|
+
pdf.line_width prev_line_width
|
51
|
+
end
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|