prawndown-ext 0.1.4 → 0.1.6

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: 642c5434cd34aa487ce5925919335736ac3ad47225eceed66c1e23d0cef1baf2
4
- data.tar.gz: 6567f31eb143ca6bca5135ed3605edc8ba827272351953e2d68488c0eb6f9e79
3
+ metadata.gz: add25cd5ac828d350ccf78f66898be73e08697a8cae07ade7eed136477665d1a
4
+ data.tar.gz: 25dfd70414948ad46abd0436b94b1c5283391a2be26ae9f87a7fdcf1238b97eb
5
5
  SHA512:
6
- metadata.gz: 47933fa1144ec46a86dc0a2d5aa48fb4c06d2632075b818d70ecf8a14be1316239ff8a56f735ca01e51bea274d6a741d863e949d694a5ba698dc986b4154e847
7
- data.tar.gz: c06b397f36764c87ec95dfe9e3611440720b5074d0c81f0a51f4bd93008d564f543c52a5e2309c23c591c448c55cbe184eedc7e05737b1a488150ce91288b6d6
6
+ metadata.gz: d8fb1a470a66603332ab42a70b010547775d078497fd79bf060349f232fae89b99fc6f83a841331b79b98d71e0e3054737141b6c71e4c098799bee2dcf854b3c
7
+ data.tar.gz: e90f324a7f615941a5ed9c066f3e88ebd6f9094ee6cdf20bf0f92b7affa0b77b4cadcf6b3d4aa2ff68e602e8f8a884f8019596106dc99f8111de7e4dfa0938b7
@@ -9,7 +9,10 @@ module PrawndownExt
9
9
  "header4_size" => 18,
10
10
  "header5_size" => 16,
11
11
  "header6_size" => 14,
12
- "quote_size" => 14
12
+ "quote_size" => 14,
13
+ "quote_font_spacing" => nil,
14
+ "quote_font" => nil,
15
+ "quote_margin" => 20,
13
16
  }
14
17
 
15
18
  MATCHERS = {
@@ -30,7 +33,7 @@ module PrawndownExt
30
33
 
31
34
  # Images
32
35
  /!\[([^\[]+)\]\(([^\)]+)\)/ => '<command_break>{"command":"img", "alt":"\1", "path":"\2"}<command_break>',
33
- /^> (.+)/ => '<command_break>{"command":"quote","margin":20,"text":"<font size=\'QUOTE_SIZE\'>\\1</font>"}<command_break>', # Quote
36
+ /^> (.+)/ => '<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
34
37
 
35
38
  # Stuff to process last
36
39
  /\[([^\[]+)\]\(([^\)]+)\)/ => '<link href="\2">\1</link>', # Link
@@ -57,6 +60,18 @@ module PrawndownExt
57
60
  end
58
61
 
59
62
  def replace_options text
63
+ # remove quote font if it doesnt exist
64
+ if @options["quote_font"].nil?
65
+ text = text.gsub("name='QUOTE_FONT' ", "")
66
+ @options.delete("quote_font")
67
+ end
68
+
69
+ # remove quote spacing if it doesnt exist
70
+ if @options["quote_font_spacing"].nil?
71
+ text = text.gsub("character_spacing='QUOTE_FONT_SPACING' ", "")
72
+ @options.delete("quote_font_spacing")
73
+ end
74
+
60
75
  DEFAULT_OPTIONS.keys.each do |replacer|
61
76
  if @options.key?(replacer)
62
77
  text = text.gsub(replacer.upcase, @options[replacer].to_s)
@@ -76,16 +91,10 @@ module PrawndownExt
76
91
  final_string.gsub(markdown_matcher, prawn_tag)
77
92
  end
78
93
 
94
+ result = replace_options result
95
+
79
96
  result = result.split("<command_break>")
80
97
 
81
- i = 0
82
-
83
- # replaces optional values here
84
- while i < result.length
85
- result[i] = replace_options result[i]
86
- i += 1
87
- end
88
-
89
98
  result
90
99
 
91
100
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PrawndownExt
4
4
  module Ext
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  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.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix