mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
57d51bb5f4
This commit normalizes the type representation of `stroking_color` and `non_stroking_color` values. Thanks to @dhdaines for pointing out this inconsistency. Previously, `pdfplumber` passed along `pdfminer.six`'s colors without normalization. Due to quirks in `pdfminer.six`'s color handling, this meant that those values could be floats, ints, lists, or tuples. This commit normalizes all color values (when non-None) into n-tuples, where (val,) represents grayscale colors, (val, val, val) represents RBG, and (val, val, val, val) represents CMYK colors. This should solve the consistency issue, although might cause breaking changes to code that filters for non-tuple values — e.g., `[c for c in page.chars if c == [1, 0 0]]`. Although breaking changes are unpleasant, I think the tradeoff for longer-term consistency is worth it.