K 所以我不得不用这个完全进入野兽模式,并将随机的文档拼凑在一起。这是一个示例,如果您想在 CSS.AllowedProperties 区域中启用弹性框 CSS(甚至不必配置它)。
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowImportant', true);
$config->set('CSS.AllowTricky', true);
$config->set('CSS.Proprietary', true);
$config->set('CSS.Trusted', true);
$css_definition = $config->getDefinition('CSS');
// redefine this to add the flex attribute
$css_definition->info['display'] = new HTMLPurifier_AttrDef_Enum(
[
'inline',
'block',
'list-item',
'run-in',
'compact',
'marker',
'table',
'inline-block',
'inline-table',
'table-row-group',
'table-header-group',
'table-footer-group',
'table-row',
'table-column-group',
'table-column',
'table-cell',
'table-caption',
'none',
'flex'
]
);
$css_definition->info['flex-direction'] = new HTMLPurifier_AttrDef_Enum(
[
'column',
'column-reverse',
'row',
'row-reverse'
]
);
$css_definition->info['flex-wrap'] = new HTMLPurifier_AttrDef_Enum(
[
'wrap',
'nowrap',
'wrap-reverse'
]
);
$css_definition->info['justify-content'] = new HTMLPurifier_AttrDef_Enum(
[
'center',
'flex-start',
'flex-end',
'space-around',
'space-between'
]
);
$css_definition->info['align-items'] = new HTMLPurifier_AttrDef_Enum(
[
'center',
'flex-start',
'flex-end',
'stretch',
'baseline'
]
);
$css_definition->info['align-content'] = new HTMLPurifier_AttrDef_Enum(
[
'space-between',
'space-around',
'stretch',
'center',
'flex-start',
'flex-end'
]
);
$css_definition->info['flex-basis'] = new HTMLPurifier_AttrDef_CSS_Percentage();
$purifier = new HTMLPurifier($config);