asciidoctor-pdf 1.5.0.alpha.13 → 1.5.0.alpha.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +131 -4
  3. data/Gemfile +8 -1
  4. data/README.adoc +199 -36
  5. data/Rakefile +1 -0
  6. data/asciidoctor-pdf.gemspec +4 -4
  7. data/data/themes/base-theme.yml +9 -2
  8. data/data/themes/default-theme.yml +34 -20
  9. data/docs/theming-guide.adoc +1147 -268
  10. data/lib/asciidoctor-pdf/asciidoctor_ext/image.rb +7 -1
  11. data/lib/asciidoctor-pdf/converter.rb +841 -409
  12. data/lib/asciidoctor-pdf/core_ext.rb +1 -0
  13. data/lib/asciidoctor-pdf/core_ext/numeric.rb +12 -8
  14. data/lib/asciidoctor-pdf/core_ext/object.rb +6 -0
  15. data/lib/asciidoctor-pdf/core_ext/string.rb +15 -0
  16. data/lib/asciidoctor-pdf/formatted_text/inline_destination_marker.rb +5 -0
  17. data/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +75 -28
  18. data/lib/asciidoctor-pdf/formatted_text/inline_image_renderer.rb +3 -2
  19. data/lib/asciidoctor-pdf/formatted_text/transform.rb +97 -89
  20. data/lib/asciidoctor-pdf/index_catalog.rb +119 -0
  21. data/lib/asciidoctor-pdf/measurements.rb +58 -0
  22. data/lib/asciidoctor-pdf/pdf-core_ext.rb +1 -0
  23. data/lib/asciidoctor-pdf/{pdf_core_ext → pdf-core_ext}/page.rb +3 -7
  24. data/lib/asciidoctor-pdf/pdfmark.rb +33 -0
  25. data/lib/asciidoctor-pdf/prawn-svg_ext.rb +4 -0
  26. data/lib/asciidoctor-pdf/prawn-svg_ext/interface.rb +10 -0
  27. data/lib/asciidoctor-pdf/prawn-table_ext.rb +3 -0
  28. data/lib/asciidoctor-pdf/prawn-table_ext/cell/asciidoc.rb +69 -0
  29. data/lib/asciidoctor-pdf/prawn-table_ext/cell/text.rb +12 -0
  30. data/lib/asciidoctor-pdf/prawn_ext/extensions.rb +89 -76
  31. data/lib/asciidoctor-pdf/prawn_ext/images.rb +0 -1
  32. data/lib/asciidoctor-pdf/roman_numeral.rb +1 -1
  33. data/lib/asciidoctor-pdf/rouge_ext/formatters/prawn.rb +51 -11
  34. data/lib/asciidoctor-pdf/rouge_ext/themes/pastie.rb +64 -59
  35. data/lib/asciidoctor-pdf/sanitizer.rb +53 -2
  36. data/lib/asciidoctor-pdf/theme_loader.rb +8 -21
  37. data/lib/asciidoctor-pdf/version.rb +1 -1
  38. metadata +19 -13
  39. data/docs/theme-schema.json +0 -114
  40. data/lib/asciidoctor-pdf/pdf_core_ext.rb +0 -2
  41. data/lib/asciidoctor-pdf/pdf_core_ext/pdf_object.rb +0 -25
  42. data/lib/asciidoctor-pdf/pdfmarks.rb +0 -35
@@ -1,114 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "title": "Theme Definition",
4
- "description": "A JSON schema for describing the available keys and value types for an Asciidoctor PDF theme. Status: Incomplete; early draft.",
5
- "definitions": {
6
- // FIXME add RGB and CMYK arrays
7
- "color": {
8
- "type": "string",
9
- "pattern": "^#?[a-fA-F0-9]{3,6}$"
10
- },
11
- "font_style": {
12
- "type": "string",
13
- "enum": ["normal", "bold", "italic", "bold_italic"]
14
- },
15
- "measurement": {
16
- "oneOf": [
17
- {
18
- "type": "string",
19
- "pattern": "^[0-9]+(?:\\.[0-9]+)?(?:in|mm|cm|pt)?$"
20
- },
21
- {
22
- // FIXME technically, numbers < 0 must have a leading 0 (e.g., 0.8)
23
- "type": "number"
24
- }
25
- ]
26
- },
27
- "text_alignment": {
28
- "type": "string",
29
- "enum": ["left", "center", "right", "justify"]
30
- }
31
- },
32
- "type": "object",
33
- "properties": {
34
- "page_background_color": {
35
- "$ref": "#/definitions/color",
36
- "default": "#FFFFFF"
37
- },
38
- "page_background_image": {
39
- "type": "string"
40
- },
41
- "page_layout": {
42
- "type": "string",
43
- "enum": ["portrait", "landscape"],
44
- "default": "portrait"
45
- },
46
- "page_margin": {
47
- "type": "array",
48
- "minItems": 4,
49
- "maxItems": 4,
50
- "items": {
51
- "$ref": "#/definitions/measurement"
52
- },
53
- "additionalItems": false
54
- },
55
- "page_size": {
56
- "oneOf": [
57
- {
58
- "type": "string",
59
- "enum": ["A4", "Executive", "Folio", "Legal", "Letter", "Tabloid"]
60
- },
61
- {
62
- "type": "array",
63
- "minItems": 2,
64
- "maxItems": 2,
65
- "items": {
66
- "$ref": "#/definitions/measurement"
67
- }
68
- }
69
- ],
70
- "default": "Letter"
71
- },
72
- "base_align": {
73
- "$ref": "#/definitions/text_alignment",
74
- "default": "left"
75
- },
76
- "base_border_color": {
77
- "$ref": "#/definitions/color"
78
- },
79
- "base_border_radius": {
80
- "type": "number"
81
- },
82
- "base_border_width": {
83
- "type": "number"
84
- },
85
- "base_font_color": {
86
- "$ref": "#/definitions/color",
87
- "default": "#000000"
88
- },
89
- "base_font_family": {
90
- "type": "string",
91
- "default": "Helvetica"
92
- },
93
- "base_font_size": {
94
- "type": "number",
95
- "default": 12
96
- },
97
- "base_font_style": {
98
- "$ref": "#/definitions/font_style",
99
- "default": "normal"
100
- },
101
- "base_line_height": {
102
- "type": "number"
103
- },
104
- "base_line_height_length": {
105
- "$ref": "#/definitions/measurement"
106
- },
107
- "base_font_size_large": {
108
- "type": "number"
109
- },
110
- "base_font_size_small": {
111
- "type": "number"
112
- }
113
- }
114
- }
@@ -1,2 +0,0 @@
1
- require_relative 'pdf_core_ext/pdf_object'
2
- require_relative 'pdf_core_ext/page'
@@ -1,25 +0,0 @@
1
- module Asciidoctor
2
- module PdfCore
3
- module PdfObject
4
- # Convert the string to a PDF literal string if it can be encoded as ASCII-8BIT.
5
- # Otherwise, return the specified string.
6
- #--
7
- # QUESTION mixin to String and NilClass as to_pdf_value?
8
- def str2pdfval string
9
- if string && string.ascii_only?
10
- ::PDF::Core::LiteralString.new(string.encode ::Encoding::ASCII_8BIT)
11
- else
12
- string
13
- end
14
- end
15
-
16
- # Convert the string to a PDF object, first attempting to
17
- # convert it to a PDF literal string.
18
- #--
19
- # QUESTION mixin to String and NilClass as to_pdf_object?
20
- def str2pdfobj string
21
- ::PDF::Core::PdfObject(str2pdfval string)
22
- end
23
- end
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- module Asciidoctor
2
- module Pdf
3
- class Pdfmarks
4
- include ::Asciidoctor::Pdf::Sanitizer
5
- include ::Asciidoctor::PdfCore::PdfObject
6
-
7
- def initialize doc
8
- @doc = doc
9
- end
10
-
11
- def generate
12
- current_datetime = ::DateTime.now.strftime '%Y%m%d%H%M%S'
13
- doc = @doc
14
- # FIXME use sanitize: :plain_text once available
15
- content = <<-EOS
16
- [ /Title #{str2pdfobj sanitize(doc.doctitle use_fallback: true)}
17
- /Author #{str2pdfobj(doc.attr 'authors')}
18
- /Subject #{str2pdfobj(doc.attr 'subject')}
19
- /Keywords #{str2pdfobj(doc.attr 'keywords')}
20
- /ModDate (D:#{current_datetime})
21
- /CreationDate (D:#{current_datetime})
22
- /Creator (Asciidoctor PDF #{::Asciidoctor::Pdf::VERSION}, based on Prawn #{::Prawn::VERSION})
23
- /Producer #{str2pdfobj(doc.attr 'publisher')}
24
- /DOCINFO pdfmark
25
- EOS
26
- content
27
- end
28
-
29
- def generate_file pdf_file
30
- # QUESTION should we use the extension pdfmeta to be more clear?
31
- ::IO.write %(#{pdf_file}marks), generate
32
- end
33
- end
34
- end
35
- end