prawndown-ext 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bd6519db873bccdf6e70d074fef2de91fed77183cf0bc3d5c98c7141a9ed401
4
- data.tar.gz: 6c1437518072c4a8f4e638de7d4d2afb57f9486118393d426ca72a37b5295e55
3
+ metadata.gz: cde96e249677d9a8796584e537c0466f30cf98764c16eafe3fd08b82fcecebee
4
+ data.tar.gz: 664c9251c77bfe9a783d2ac26ecaf4a506c0f87e604a097ba49c6ae4c613015a
5
5
  SHA512:
6
- metadata.gz: 4f998d15bf130fe474b49c511933814ef921f5357206ab8dc04f627464d443618a0e3b2f83b2b411244736b49689f423d27ad6cd16793ba724608c83e658cca9
7
- data.tar.gz: 654ab49b3a3e398ca247609ce5e4035494c7c83cacce614a96cb7b02d729b41dfc15fb53c683bd97a6d86365400986af220e931ef7ea921b720b7f8dc85d4b2f
6
+ metadata.gz: a2a036fb2d2a05537dd8d780b675b9574751afab2f9449630de714586a39c2451d0ed22149299b9cb86e15e362f05839ba2736bff650e770db1e4fb4d7d3c702
7
+ data.tar.gz: 95ba8579b3addb4a791a8e6d00eb91a0d98d2f36cf5f133a2349a7b4b2579c391dfe024b7f279f138ddcc68cefa21c5ade556c81e85a85035f362014a7a5630d
@@ -31,33 +31,41 @@ module PrawndownExt
31
31
  "header5_font" => nil,
32
32
  "header6_font" => nil,
33
33
  "quote_margin" => 20,
34
+ "header1_margin" => 4,
35
+ "header2_margin" => 4,
36
+ "header3_margin" => 4,
37
+ "header4_margin" => 4,
38
+ "header5_margin" => 4,
39
+ "header6_margin" => 4,
34
40
  }
35
41
 
36
42
  MATCHERS = {
43
+ # Removes carriage returns, they cause issues
44
+ /\r/ => '',
37
45
  /<iframe ([^\[]+)<\/iframe>/ => '', # Embeds are just removed
38
46
  /(\*\*|__)(.*?)\1/ => '<b>\2</b>', # Bold
39
47
  /(\*|_)(.*?)\1/ => '<i>\2</i>', # Italic
40
48
  /\~\~(.*?)\~\~/ => '<strikethrough>\1</strikethrough>', # Strikethrough
41
49
  ## Regular markdown
42
50
  ## Header 1
43
- /^# (.+)/ => '<command_break>{"command":"header1","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER1_FONT\' size=\'HEADER1_SIZE\'><b>\1</b></font>"}<command_break>',
51
+ /(^# )(.+)/ => '<command_break>{"command":"header1","margin":HEADER1_MARGIN,"text":"<font name=\'HEADER1_FONT\' size=\'HEADER1_SIZE\'><b>\2</b></font>"}<command_break>',
44
52
  ## Header 2
45
- /^## (.+)/ => '<command_break>{"command":"header2","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER2_FONT\' size=\'HEADER2_SIZE\'><b>\1</b></font>"}<command_break>',
53
+ /(^## )(.*)/ => '<command_break>{"command":"header2","margin":HEADER2_MARGIN,"text":"<font name=\'HEADER2_FONT\' size=\'HEADER2_SIZE\'><b>\2</b></font>"}<command_break>',
46
54
  ## Header 3
47
- /^### (.+)/ => '<command_break>{"command":"header3","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER3_FONT\' size=\'HEADER3_SIZE\'><b>\1</b></font>"}<command_break>',
55
+ /(^### )(.*)/ => '<command_break>{"command":"header3","margin":HEADER3_MARGIN,"text":"<font name=\'HEADER3_FONT\' size=\'HEADER3_SIZE\'><b>\2</b></font>"}<command_break>',
48
56
  ## Header 4
49
- /^#### (.+)/ => '<command_break>{"command":"header4","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER4_FONT\' size=\'HEADER4_SIZE\'><b>\1</b></font>"}<command_break>',
57
+ /(^#### )(.*)/ => '<command_break>{"command":"header4","margin":HEADER4_MARGIN,"text":"<font name=\'HEADER4_FONT\' size=\'HEADER4_SIZE\'><b>\2</b></font>"}<command_break>',
50
58
  ## Header 5
51
- /^##### (.+)/ => '<command_break>{"command":"header5","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER5_FONT\' size=\'HEADER5_SIZE\'><b>\1</b></font>"}<command_break>',
59
+ /(^##### )(.*)/ => '<command_break>{"command":"header5","margin":HEADER5_MARGIN,"text":"<font name=\'HEADER5_FONT\' size=\'HEADER5_SIZE\'><b>\2</b></font>"}<command_break>',
52
60
  ## Header 6
53
- /^###### (.+)/ => '<command_break>{"command":"header6","margin":QUOTE_MARGIN,"text":"<font name=\'HEADER6_FONT\' size=\'HEADER6_SIZE\'><b>\1</b></font>"}<command_break>',
61
+ /(^###### )(.*)/ => '<command_break>{"command":"header6","margin":HEADER6_MARGIN,"text":"<font name=\'HEADER6_FONT\' size=\'HEADER6_SIZE\'><b>\2</b></font>"}<command_break>',
54
62
 
55
63
  # Command Break items
56
64
  # These split into multiple commands for output
57
65
 
58
66
  # Images
59
67
  /!\[([^\[]+)\]\(([^\)]+)\)/ => '<command_break>{"command":"img", "alt":"\1", "path":"\2"}<command_break>',
60
- /^> (.+)/ => '<command_break>{"command":"quote","margin":QUOTE_MARGIN,"text":"<font name=\'QUOTE_FONT\' character_spacing=\'QUOTE_FONT_SPACING\' size=\'QUOTE_SIZE\'>\\1</font>"}<command_break>', # Quote
68
+ /^> (.+)/ => '<command_break>{"command":"quote","margin":QUOTE_MARGIN,"text":"<font name=\'QUOTE_FONT\' character_spacing=\'QUOTE_FONT_SPACING\' size=\'QUOTE_SIZE\'>\1</font>"}<command_break>', # Quote
61
69
 
62
70
  # Stuff to process last
63
71
  /\[([^\[]+)\]\(([^\)]+)\)/ => '<link href="\2">\1</link>', # Link
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PrawndownExt
4
4
  module Ext
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.9"
6
6
  end
7
7
  end
data/lib/prawndown-ext.rb CHANGED
@@ -31,7 +31,7 @@ module PrawndownExt
31
31
  if !options.key?(args["command"] + "_line_spacing")
32
32
  options[args["command"] + "_line_spacing"] = 0
33
33
  end
34
-
34
+
35
35
  if !options.key?("margin")
36
36
  args["margin"] = 0
37
37
  end
@@ -45,9 +45,23 @@ module PrawndownExt
45
45
  end
46
46
 
47
47
  def self.cl_img args, pdf, options
48
- pdf.image(args["path"],
49
- width: pdf.bounds.width,
50
- position: :center)
48
+ if options.key?("no_image")
49
+ if options["no_image"]
50
+ return
51
+ end
52
+ end
53
+
54
+ file = args["path"]
55
+
56
+ if !File.file?(file)
57
+ file = "." + file
58
+ end
59
+
60
+ if File.extname(file) != ".gif"
61
+ pdf.image(file,
62
+ width: pdf.bounds.width,
63
+ position: :center)
64
+ end
51
65
  end
52
66
 
53
67
 
@@ -78,6 +92,7 @@ module PrawndownExt
78
92
  # markdown '**Important:** We _hope_ you enjoy your stay!'
79
93
  # end
80
94
  def markdown(string, options: {})
95
+
81
96
  if !options.key?("default_line_spacing")
82
97
  options["default_line_spacing"] = 0
83
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawndown-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix
@@ -30,8 +30,8 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: 2.5.0
32
32
  description: Extension of Prawndown to include additional Markdown features. Currently
33
- supports custom header sizes, removing iframe content. Need to write more to make
34
- images work.
33
+ supports custom header sizes, fonts, and other properties; removing iframe content,
34
+ and support for images and quotes.
35
35
  email:
36
36
  - labadore1844@gmail.com
37
37
  executables: []
@@ -61,5 +61,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements: []
62
62
  rubygems_version: 3.6.9
63
63
  specification_version: 4
64
- summary: Extension of Prawndown to include additional features.
64
+ summary: Extension of Prawndown to include additional features, such as customizing
65
+ text fonts, sizes, and support for images and quotes.
65
66
  test_files: []