asciidoctor-pdf 1.5.0.beta.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +277 -2
- data/LICENSE.adoc +1 -1
- data/NOTICE.adoc +1 -1
- data/README.adoc +486 -292
- data/asciidoctor-pdf.gemspec +12 -11
- data/bin/asciidoctor-pdf +2 -6
- 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 +22 -4
- data/data/themes/default-theme.yml +59 -29
- data/data/themes/default-with-fallback-font-theme.yml +4 -17
- data/docs/theming-guide.adoc +1647 -167
- data/lib/asciidoctor/pdf/converter.rb +4489 -0
- data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/abstract_block.rb +2 -0
- data/lib/asciidoctor/pdf/ext/asciidoctor/abstract_node.rb +7 -0
- data/lib/{asciidoctor-pdf/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/document.rb +2 -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/asciidoctor_ext → asciidoctor/pdf/ext/asciidoctor}/section.rb +9 -6
- data/lib/asciidoctor/pdf/ext/asciidoctor.rb +11 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/array.rb +6 -0
- data/lib/asciidoctor/pdf/ext/core/file.rb +9 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/hash.rb +2 -0
- data/lib/{asciidoctor-pdf/core_ext → asciidoctor/pdf/ext/core}/numeric.rb +5 -3
- 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/core_ext → asciidoctor/pdf/ext/core}/regexp.rb +2 -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 +16 -12
- 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/prawn-svg_ext.rb → asciidoctor/pdf/ext/prawn-svg.rb} +3 -1
- 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/prawn-table_ext → asciidoctor/pdf/ext/prawn-table}/cell.rb +10 -10
- 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 → asciidoctor/pdf/ext/rouge}/themes/asciidoctor_pdf_default.rb +2 -0
- 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 +31 -7
- data/lib/{asciidoctor-pdf → asciidoctor/pdf}/formatted_text/parser.treetop +3 -4
- 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 +4 -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 -1
- data/lib/asciidoctor/pdf.rb +15 -1
- data/lib/asciidoctor-pdf/converter.rb +2 -3824
- data/lib/asciidoctor-pdf/version.rb +3 -6
- data/lib/asciidoctor-pdf.rb +3 -4
- metadata +130 -85
- data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +0 -24
- data/lib/asciidoctor-pdf/asciidoctor_ext/logging_shim.rb +0 -25
- data/lib/asciidoctor-pdf/asciidoctor_ext.rb +0 -8
- data/lib/asciidoctor-pdf/core_ext/ostruct.rb +0 -8
- data/lib/asciidoctor-pdf/core_ext.rb +0 -6
- data/lib/asciidoctor-pdf/formatted_text/formatter.rb +0 -40
- data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +0 -21
- data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +0 -160
- data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +0 -46
- data/lib/asciidoctor-pdf/formatted_text/inline_text_aligner.rb +0 -20
- data/lib/asciidoctor-pdf/formatted_text/text_background_and_border_renderer.rb +0 -45
- data/lib/asciidoctor-pdf/formatted_text/transform.rb +0 -294
- data/lib/asciidoctor-pdf/implicit_header_processor.rb +0 -63
- data/lib/asciidoctor-pdf/index_catalog.rb +0 -127
- 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-table_ext/cell/asciidoc.rb +0 -69
- data/lib/asciidoctor-pdf/prawn-table_ext.rb +0 -4
- data/lib/asciidoctor-pdf/prawn_ext/coderay_encoder.rb +0 -115
- data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +0 -904
- data/lib/asciidoctor-pdf/prawn_ext/images.rb +0 -51
- data/lib/asciidoctor-pdf/prawn_ext.rb +0 -5
- data/lib/asciidoctor-pdf/roman_numeral.rb +0 -126
- data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +0 -175
- data/lib/asciidoctor-pdf/rouge_ext/themes/bw.rb +0 -38
- data/lib/asciidoctor-pdf/rouge_ext.rb +0 -4
- data/lib/asciidoctor-pdf/sanitizer.rb +0 -101
- data/lib/asciidoctor-pdf/temporary_path.rb +0 -13
- data/lib/asciidoctor-pdf/theme_loader.rb +0 -280
- data/lib/asciidoctor-pdf/ttfunk_ext.rb +0 -8
@@ -1,33 +0,0 @@
|
|
1
|
-
module Asciidoctor
|
2
|
-
module PDF
|
3
|
-
class Pdfmark
|
4
|
-
include ::Asciidoctor::PDF::Sanitizer
|
5
|
-
|
6
|
-
def initialize doc
|
7
|
-
@doc = doc
|
8
|
-
end
|
9
|
-
|
10
|
-
def generate
|
11
|
-
doc = @doc
|
12
|
-
# FIXME use sanitize: :plain_text once available
|
13
|
-
content = <<~EOS
|
14
|
-
[ /Title #{sanitize(doc.doctitle use_fallback: true).to_pdf}
|
15
|
-
/Author #{(doc.attr 'authors').to_pdf}
|
16
|
-
/Subject #{(doc.attr 'subject').to_pdf}
|
17
|
-
/Keywords #{(doc.attr 'keywords').to_pdf}
|
18
|
-
/ModDate #{date = ::Time.now.to_pdf}
|
19
|
-
/CreationDate #{date}
|
20
|
-
/Creator (Asciidoctor PDF #{::Asciidoctor::PDF::VERSION}, based on Prawn #{::Prawn::VERSION})
|
21
|
-
/Producer #{(doc.attr 'publisher').to_pdf}
|
22
|
-
/DOCINFO pdfmark
|
23
|
-
EOS
|
24
|
-
content
|
25
|
-
end
|
26
|
-
|
27
|
-
def generate_file pdf_file
|
28
|
-
# QUESTION should we use the extension pdfmeta to be more clear?
|
29
|
-
::File.write %(#{pdf_file}mark), generate
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Prawn; module SVG
|
2
|
-
class Interface
|
3
|
-
def resize opts = {}
|
4
|
-
sizing = document.sizing
|
5
|
-
sizing.requested_width = opts[:width]
|
6
|
-
sizing.requested_height = opts[:height]
|
7
|
-
sizing.calculate
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end; end unless Prawn::SVG::Interface.method_defined? :resize
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module Prawn; class Table; class Cell
|
2
|
-
class AsciiDoc < Cell
|
3
|
-
attr_accessor :align
|
4
|
-
attr_accessor :valign
|
5
|
-
|
6
|
-
def initialize pdf, opts = {}
|
7
|
-
@font_options = {}
|
8
|
-
super pdf, [], opts
|
9
|
-
end
|
10
|
-
|
11
|
-
def font_style= val
|
12
|
-
@font_options[:style] = val
|
13
|
-
end
|
14
|
-
|
15
|
-
def text_color= val
|
16
|
-
@font_options[:color] = val
|
17
|
-
end
|
18
|
-
|
19
|
-
def size= val
|
20
|
-
@font_options[:size] = val
|
21
|
-
end
|
22
|
-
|
23
|
-
def font= val
|
24
|
-
@font_options[:family] = val
|
25
|
-
end
|
26
|
-
|
27
|
-
# NOTE automatic image sizing only works if cell has fixed width
|
28
|
-
def dry_run
|
29
|
-
cell = self
|
30
|
-
max_height = nil
|
31
|
-
height, _, _ = @pdf.dry_run do
|
32
|
-
max_height = bounds.height
|
33
|
-
# NOTE we should be able to use cell.max_width, but returns 0 in some conditions (like when colspan > 1)
|
34
|
-
indent cell.padding_left, bounds.width - cell.width + cell.padding_right do
|
35
|
-
# HACK force margin_top to be applied
|
36
|
-
move_down 0.0001
|
37
|
-
# TODO truncate margin bottom of last block
|
38
|
-
convert_content_for_block cell.content
|
39
|
-
end
|
40
|
-
end
|
41
|
-
# FIXME prawn-table doesn't support cell taller than a single page
|
42
|
-
[max_height, height].min
|
43
|
-
end
|
44
|
-
|
45
|
-
def natural_content_width
|
46
|
-
# QUESTION can we get a better estimate of the natural width?
|
47
|
-
@natural_width ||= (@pdf.bounds.width - padding_left - padding_right)
|
48
|
-
end
|
49
|
-
|
50
|
-
def natural_content_height
|
51
|
-
# NOTE when natural_content_height is called, we already know max width
|
52
|
-
@natural_height ||= dry_run
|
53
|
-
end
|
54
|
-
|
55
|
-
def draw_content
|
56
|
-
pdf = @pdf
|
57
|
-
# NOTE draw_bounded_content adds FPTolerance to width and height, which causes content to overflow
|
58
|
-
pdf.bounds.instance_variable_set :@width, spanned_content_width
|
59
|
-
pdf.bounds.instance_variable_set :@height, spanned_content_height
|
60
|
-
if @valign != :top && (excess_y = spanned_content_height - natural_content_height) > 0
|
61
|
-
pdf.move_down(@valign == :center ? (excess_y.fdiv 2) : excess_y)
|
62
|
-
end
|
63
|
-
# TODO apply horizontal alignment (right now must use alignment on content block)
|
64
|
-
# QUESTION inherit table cell font properties?
|
65
|
-
pdf.convert_content_for_block content
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end; end; end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
######################################################################
|
2
|
-
#
|
3
|
-
# This file was copied from Prawn (manual/syntax_highlight.rb) and
|
4
|
-
# modified for use with Asciidoctor PDF.
|
5
|
-
#
|
6
|
-
# Prawn is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# Prawn is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with Prawn. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
#
|
19
|
-
# Copyright (C) Felipe Doria
|
20
|
-
# Copyright (C) 2014 OpenDevise Inc. and the Asciidoctor Project
|
21
|
-
#
|
22
|
-
######################################################################
|
23
|
-
|
24
|
-
require 'coderay'
|
25
|
-
|
26
|
-
# Registers a to_prawn method with CodeRay. The method returns an array of hashes to be
|
27
|
-
# used with Prawn::Text.formatted_text(array).
|
28
|
-
#
|
29
|
-
# Usage:
|
30
|
-
#
|
31
|
-
# CodeRay.scan(string, :ruby).to_prawn
|
32
|
-
#
|
33
|
-
module Asciidoctor
|
34
|
-
module Prawn
|
35
|
-
class CodeRayEncoder < ::CodeRay::Encoders::Encoder
|
36
|
-
register_for :to_prawn
|
37
|
-
|
38
|
-
# Manni theme from Pygments
|
39
|
-
COLORS = {
|
40
|
-
default: '333333',
|
41
|
-
annotation: '9999FF',
|
42
|
-
attribute_name: '4F9FCF',
|
43
|
-
attribute_value: 'D44950',
|
44
|
-
class: '00AA88',
|
45
|
-
class_variable: '003333',
|
46
|
-
color: 'FF6600',
|
47
|
-
comment: '999999',
|
48
|
-
constant: '336600',
|
49
|
-
directive: '006699',
|
50
|
-
doctype: '009999',
|
51
|
-
entity: '999999',
|
52
|
-
float: 'FF6600',
|
53
|
-
function: 'CC00FF',
|
54
|
-
important: '9999FF',
|
55
|
-
inline_delimiter: 'EF804F',
|
56
|
-
instance_variable: '003333',
|
57
|
-
integer: 'FF6600',
|
58
|
-
key: '006699',
|
59
|
-
keyword: '006699',
|
60
|
-
method: 'CC00FF',
|
61
|
-
namespace: '00CCFF',
|
62
|
-
predefined_type: '007788',
|
63
|
-
regexp: '33AAAA',
|
64
|
-
string: 'CC3300',
|
65
|
-
symbol: 'FFCC33',
|
66
|
-
tag: '2F6F9F',
|
67
|
-
type: '007788',
|
68
|
-
value: '336600'
|
69
|
-
}
|
70
|
-
|
71
|
-
LF = %(\n)
|
72
|
-
NoBreakSpace = %(\u00a0)
|
73
|
-
InnerIndent = %(\n )
|
74
|
-
GuardedIndent = %(\u00a0)
|
75
|
-
GuardedInnerIndent = %(\n\u00a0)
|
76
|
-
|
77
|
-
def setup options
|
78
|
-
super
|
79
|
-
@out = []
|
80
|
-
@open = []
|
81
|
-
# NOTE tracks whether text token begins at the start of a line
|
82
|
-
@start_of_line = true
|
83
|
-
end
|
84
|
-
|
85
|
-
def text_token text, kind
|
86
|
-
if text == LF
|
87
|
-
@out << { text: text }
|
88
|
-
@start_of_line = true
|
89
|
-
# NOTE text is nil and kind is :error when CodeRay ends parsing on an error
|
90
|
-
elsif text
|
91
|
-
# NOTE add guard character to prevent Prawn from trimming indentation
|
92
|
-
text[0] = GuardedIndent if @start_of_line && (text.start_with? ' ')
|
93
|
-
text.gsub! InnerIndent, GuardedInnerIndent if text.include? InnerIndent
|
94
|
-
|
95
|
-
# NOTE this optimization assumes we don't support/use background colors
|
96
|
-
if text.rstrip.empty?
|
97
|
-
@out << { text: text }
|
98
|
-
else
|
99
|
-
# QUESTION should we default to no color?
|
100
|
-
@out << { text: text, color: (COLORS[kind] || COLORS[@open[-1]] || COLORS[:default]) }
|
101
|
-
end
|
102
|
-
@start_of_line = text.end_with? LF
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def begin_group kind
|
107
|
-
@open << kind
|
108
|
-
end
|
109
|
-
|
110
|
-
def end_group kind
|
111
|
-
@open.pop
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|