normalizePaper function

String normalizePaper(
  1. String paper
)

Normalizes the paper name, returning the string used for CSS @page size (A4 / letter / B5 …). Returns A4 for an empty or unrecognized value, consistent with upstream WapPage's default.

Implementation

String normalizePaper(String paper) {
  final p = _expandAttr(paper).toLowerCase();
  if (p.isEmpty) return 'A4';
  if (p.startsWith('letter')) return 'letter';
  if (p.startsWith('legal')) return 'legal';
  if (p.startsWith('a3')) return 'A3';
  if (p.startsWith('a5')) return 'A5';
  if (p.startsWith('b5')) return 'B5';
  if (p.startsWith('a4')) return 'A4';
  return 'A4';
}