-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
As described here, a github actions workflow should be created for this repository which:
- takes the workflow run id from the triggering workflow
- Waits until the dispatching workflow run is completed (have a look here)
- Downloads the artifacts
- Post-processes the markdown files in order to work for docusaurus (see script draft below)
- Check if there are any differences (e.g., using git).
- If yes: automatically create pull request
Draft for post-processing script:
import re
import sys
def convert_markdown_to_html(input_file, output_file):
# Read the input file
with open(input_file, 'r') as file:
lines = file.readlines()
in_markdown_block = False
output_lines = []
current_block = []
# Iterate through each line in the input file
for line in lines:
# Check if we are entering a markdown block
if "{{% markdown %}}" in line:
in_markdown_block = True
# Retain the line before the block and start processing inside the block
output_lines.append(line.split("{{% markdown %}}")[0]) # Retain text before the marker
current_block = [] # Reset the current block for processing
continue
# Check if we are leaving a markdown block
if "{{% /markdown %}}" in line:
in_markdown_block = False
# Process the block and wrap it in <ul>
output_lines.append("<ul>") # Start the unordered list
# Add processed markdown content (list items)
for list_item in current_block:
# Process each list item inside the markdown block
match = re.match(r'([^\(]+)\s?\(`([^`]+)`\)', list_item.strip())
if match:
attribute = match.group(1).strip()
mlir_type = match.group(2).strip()
html_item = f"<li><strong>{attribute}</strong>: Enum case: {attribute} ({mlir_type})</li>"
output_lines.append(html_item)
else:
output_lines.append(f"<li>{list_item.strip()}</li>")
output_lines.append("</ul>") # Close the unordered list
output_lines.append(line.split("{{% /markdown %}}")[1]) # Retain text after the marker
continue
# Process lines inside the markdown block (for list items)
if in_markdown_block:
if line.strip().startswith("* "): # Markdown list item
current_block.append(line.strip()[2:]) # Remove "* " from the start
else:
current_block.append(line) # Add non-list content to the current block
else:
output_lines.append(line)
# Write the output to the output file
with open(output_file, 'w') as file:
file.writelines(output_lines)
print(f"HTML output written to {output_file}")
# Command-line usage
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python convert_markdown_to_html.py input_file output_file")
sys.exit(1)
input_file = sys.argv[1]
output_file = sys.argv[2]
convert_markdown_to_html(input_file, output_file)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels