Skip to content

Commit

Permalink
Fix formatting of event pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Binnette committed Feb 17, 2024
1 parent 39765ba commit 4c879a3
Show file tree
Hide file tree
Showing 274 changed files with 6,145 additions and 2,977 deletions.
886 changes: 886 additions & 0 deletions Scrapping/data.json

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions Scrapping/eventsJsonToEventsMarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,38 @@ def format_description(description):
# Split the string by newline characters
string_list = description.split("\n")

starts = [
"🗺️ Topo & GPX track:",
"📲 Download GPX",
"📏 Distance:",
"⏱️ Time:",
"📈 D+:",
"Topo & GPX track:",
"▶💡 Download GPX",
"Distance:",
"Time:",
"D+:",
]

# Create an empty list to store the formatted lines
formatted_list = []

# Loop through the string list
for line in string_list:
# Check if the line matches the pattern "==.*=="
if re.match("==.*==", line):
# Remove all "=" characters from the line
line = line.replace("== ", "")
line = line.replace(" ==", "")
line = line.replace("==", "")

if re.match("\*\*.*\*\*", line):
line = line.replace("**", "")

if re.match("^=+$", line):
line = "---------------"
elif re.match("^[\s=]+$", line):
line = ""
elif re.match("^=.*", line):
line = line.lstrip("=")
line = line.rstrip("=")
# Add "##" at the start of the line
line = "## " + line
elif any(line.startswith(x) for x in starts):
line = "* " + line

# Append the formatted line to the list
formatted_list.append(line)
Expand Down Expand Up @@ -137,14 +155,14 @@ def createMarkdownFileForEvent(event):
f.write(f"title: {title}\n")
f.write(f"---\n\n")
f.write(f"# {title}\n\n")
f.write(f"![{date_str_with_suffix}](/Stats/img/orig/{date_str_with_suffix}.jpg)\n\n")
f.write(f"![{date_str_with_suffix}](../img/orig/{date_str_with_suffix}.jpg)\n\n")
f.write(f"{description}\n\n")
f.write(f"## Stats\n\n")
f.write(f"- Start time: {start_str}\n")
f.write(f"- End time: {end_str}\n")
f.write(f"- Duration: {duration_str}\n")
f.write(f"- Time to event: {planned_str}\n")
f.write(f"- Attendees: {going}\n\n")
f.write(f"- Attendees: {going}\n")
f.write(f"- KM: {km}\n")
f.write(f"- D+: {dplus}\n")
f.write(f"- Top: {top}\n")
Expand Down
Loading

0 comments on commit 4c879a3

Please sign in to comment.