isodoc 3.7.28 → 3.7.29

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: 1bbfe742d2c836876f6c40d98f8c0a5a70d5c642dd2a8582ee0f176f242161ee
4
- data.tar.gz: 59b54ecbc16be43e5f8c415f02da2e078c49a1840c1db8de930d508753dbb28b
3
+ metadata.gz: 4f9765f3c891cca29930972e25caa9ac605eeee3c773e2619ac96f891f1fcec1
4
+ data.tar.gz: c6addf143c820531cd95c78caa380b627d0192d56d9896354851cb39110693f5
5
5
  SHA512:
6
- metadata.gz: 2191755a7cffff1ae232d205e7dafbe3359e34a602cefa018a2851c4d5789a33e12dc2ab3c8ee695f6331f3ee5f3503a84114b5734a3b5592b53d6807771987b
7
- data.tar.gz: c476a18a7bec93289fe77870b3830152d5f551d9675faf88736f527f76b2de8541e7b62e9ee5af3514ac5a3b3559d70520927ebd4819af7c83ba8502602e2077
6
+ metadata.gz: 5ce6a7be080582f6fb0c96c55e63f2f851a82a0a70d71ebf38d0a7ff3c05dab48f68295c4082680394dad10e667212af054f10d755de9ac83ba9677e27335c12
7
+ data.tar.gz: 9f6397f9157c44ad4d28518ed5a6731ae287782721c8d30825f4b749797595ba4c36e6671b3a58429e29c68f24055dd1f58a9a4a619d62fedfb296f1cfe9bad9
data/lib/isodoc/css.rb CHANGED
@@ -63,11 +63,20 @@ module IsoDoc
63
63
 
64
64
  # Font names reach font-family declarations through SCSS variables;
65
65
  # a raw multi-word name ("Source Sans 3") or a stack ("Arial, sans-serif")
66
- # emits unquoted and browsers reject or mis-parse it. Quote unless the
67
- # flavor already brings its own quoting.
66
+ # emits unquoted and browsers reject or mis-parse it. Quote per
67
+ # comma-separated segment: whole-value wrapping mangles stacks whose
68
+ # segments carry their own quotes (the string token ends at the first
69
+ # embedded quote), and generic family keywords must never be quoted.
70
+ GENERIC_CSS_FAMILIES = /\A(?:inherit|serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-sans-serif|ui-serif|ui-monospace|ui-rounded|math|fangsong)\z/i.freeze
71
+
68
72
  def quote_css_font(value)
69
- v = value.to_s.strip
70
- v.start_with?("\"", "'") ? v : "\"#{v}\""
73
+ value.to_s.split(",").map do |segment|
74
+ s = segment.strip
75
+ next s if s.empty? || GENERIC_CSS_FAMILIES.match?(s) ||
76
+ s.start_with?("\"", "'")
77
+
78
+ "\"#{s}\""
79
+ end.join(", ")
71
80
  end
72
81
 
73
82
  def scss_fontheader(is_html_css)
@@ -1,5 +1,15 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
+ # pubid_parse is a pure function of its input (the flavor registry is
4
+ # process-static), and the same docidentifier strings repeat across a
5
+ # document's references. Each miss runs every registered pubid flavor
6
+ # - and the IEEE-family parses re-register their parsanol grammar per
7
+ # call (profiled at ~54% of a warm smol collection build). Results
8
+ # memoize process-wide; the cap bounds memory on adversarial input.
9
+ PUBID_PARSE_MEMO = {}
10
+ PUBID_PARSE_MEMO_LOCK = Mutex.new
11
+ PUBID_PARSE_MEMO_MAX = 100_000
12
+
3
13
  # Wrap token sub-spans of a standard docidentifier (publisher, document
4
14
  # number, part, year, ...) in <span class="..."> markers for CSS styling.
5
15
  # Flavors opt in by overriding `annotate_docid?`; they customise span
@@ -42,6 +52,17 @@ module IsoDoc
42
52
  # the caller uses the regex fallback, which preserves the
43
53
  # original string (1.x's ParseError path).
44
54
  def pubid_parse(string)
55
+ PUBID_PARSE_MEMO_LOCK.synchronize do
56
+ return PUBID_PARSE_MEMO[string] if PUBID_PARSE_MEMO.key?(string)
57
+ end
58
+ result = pubid_parse_uncached(string)
59
+ PUBID_PARSE_MEMO_LOCK.synchronize do
60
+ PUBID_PARSE_MEMO[string] = result if PUBID_PARSE_MEMO.size < PUBID_PARSE_MEMO_MAX
61
+ end
62
+ result
63
+ end
64
+
65
+ def pubid_parse_uncached(string)
45
66
  Pubid.eager_load_flavors!
46
67
  parsed_any = false
47
68
  plain_roundtrip = false
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.7.28".freeze
2
+ VERSION = "3.7.29".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.28
4
+ version: 3.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.