diff --git a/weasyprint/css/validation.py b/weasyprint/css/validation.py index 2912e77e..08f96f9d 100644 --- a/weasyprint/css/validation.py +++ b/weasyprint/css/validation.py @@ -1585,8 +1585,7 @@ def validate_content_list_token(token): elif prototype in (('content', ()), ('content', ('ident',))): if not args: return (name, 'text') - elif args[0] in ('text', 'after', 'before'): - # TODO: first-letter should be allowed here too + elif args[0] in ('text', 'after', 'before', 'first-letter'): return (name, args[0]) elif prototype in (('counter', ('ident',)), ('counters', ('ident', 'string'))): diff --git a/weasyprint/formatting_structure/build.py b/weasyprint/formatting_structure/build.py index 38c304cc..dbe5ae45 100644 --- a/weasyprint/formatting_structure/build.py +++ b/weasyprint/formatting_structure/build.py @@ -1159,6 +1159,11 @@ def box_text(box): return '' +def box_text_first_letter(box): + text = box_text(box) + return text[0] if text else '' + + def box_text_before(box): if isinstance(box, boxes.ParentBox): return ''.join( @@ -1182,4 +1187,5 @@ def box_text_after(box): TEXT_CONTENT_EXTRACTORS = { 'text': box_text, 'before': box_text_before, - 'after': box_text_after} + 'after': box_text_after, + 'first-letter': box_text_first_letter}