` with a class "prod-spec". Inside each `
`, there will be an `
` heading, a bold text indicating "MINIMUM SPECS", and an unordered list of requirements.
### Approach
1. **Parse the Input**: Read the JSON array and extract each system's name and its corresponding requirements.
2. **Process Requirements**: Convert the HTML string of requirements into individual list items. Each list item will have a key (e.g., "OS:", "Processor:") and a value.
3. **Construct HTML**: For each system, create an HTML block with the required structure, including the heading, bold text, and list items.
4. **Compile Output**: Combine all HTML blocks into a single string, separating each system's requirements with `
`.
### Solution Code
```python
import json
import re
def reformat_html_from_json(json_input):
data = json.loads(json_input)
output = []
for entry in data:
system = entry['system']
requirement = entry['requirement']
# Remove any HTML entities and clean up the requirement string
requirement = re.sub(r'<|>', lambda m: {'<': '<', '>': '>'}[m.group()], requirement)
requirement = requirement.replace('\\n', '
')
# Extract list items
lis = re.findall(r'
(.*?)', requirement)
# Process each list item to extract key and value
list_html = []
for li in lis:
key_value = re.match(r'
(.*?)\s*(.*)', li)
if key_value:
key = key_value.group(1).strip()
value = key_value.group(2).strip().replace('
', ' ')
list_html.append(f'
{key} {value}')
# Construct the HTML block for the system
system_html = f'''
{system} System Requirements
MINIMUM SPECS
'''
output.append(system_html)
return '\n
\n'.join(output).strip()
# Example usage:
json_input = '''
[
{
"system": "Windows",
"requirement": "
\n- OS: Windows 7 (32-bit)
\n- Processor: Dual Core 2.4Ghz
\n- Memory: 2 GB RAM
\n- Graphics: GeForce 8800 GT / AMD HD 6850 / Intel HD Graphics 4400 or above
\n- DirectX: Version 11
\n- Storage: 750 MB available space
\n- Sound Card: DirectX Compatible Sound Card
\n- Additional Notes: Gamepads Recommended
\n
"
}
]
'''
print(reformat_html_from_json(json_input))
```
### Explanation
1. **Input Parsing**: The input JSON is parsed to extract each system's name and its requirements.
2. **String Cleaning**: The HTML entities in the requirements string are converted back to their respective characters, and line breaks are handled.
3. **List Item Extraction**: Each requirement list item is extracted, and its key and value are separated.
4. **HTML Construction**: For each system, an HTML block is constructed with the required structure, including the system name, "MINIMUM SPECS" text, and formatted list items.
5. **Output Compilation**: All system HTML blocks are combined into a single string, separated by `
` for clarity.
This approach ensures that the system requirements are presented in a structured and readable format, adhering to the specified guidelines.
分享