diff --git a/README.md b/README.md
index 55663ee..8fee7d8 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
## How to Create a Post
@@ -23,12 +23,6 @@ media:
- matrix
- slack
-images:
- - url: https://example.com/a.jpg
- alt_text: A
- - url: https://example.org/b.png
- alt_text: B
-
mentions:
bluesky:
- a.bsky.social
@@ -47,17 +41,19 @@ hashtags:
---
Your text content goes here.
+![A](https://example.com/a.jpg)
+![B](https://example.org/b.png)
```
**Notes on the Template:**
- Everything between the two `---` are metatags and should be in YAML format.
- "media" (Required): Ensure the media name is implemented inside the `plugins.yml`.
-- "images" (Optional): Include links to desired images. The alt_text is optional but recommended.
-
- "mentions" and "hashtags" (Optional): Follow the specified format as shown in the template.
-- "Your text content goes here." (Required): This is the content that will be posted to social media platforms. When the character limit is reached on a social media, it will be divided into several posts as a thread.
+- "Your text content goes here." (Required): This is the content that will be posted to social media platforms. When the character limit is reached on a social media, it will be divided into several posts as a thread. Note that some social media platforms do not support Markdown formatting, so use plain text only.
+
+- "images" (Optional): You can include images using Markdown format at the end of the file like this: `![Alternative text](Link to the image)`. Alternatively, you can simply drag and drop an image from your PC while adding your file.
4. **Create a Pull Request:** Once your post is ready, [create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request?tool=webui#creating-the-pull-request) to the main branch from another branch or [from your fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
diff --git a/lib/galaxy_social.py b/lib/galaxy_social.py
index ef5c2d9..ca7f641 100644
--- a/lib/galaxy_social.py
+++ b/lib/galaxy_social.py
@@ -1,13 +1,12 @@
import json
import os
+import re
import sys
from argparse import ArgumentParser
from fnmatch import filter
from importlib import import_module
-from bs4 import BeautifulSoup
from jsonschema import validate
-from markdown import markdown
from yaml import safe_load as yaml
@@ -79,8 +78,8 @@ def parse_markdown_file(self, file_path):
result, status = self.lint_markdown_file(file_path)
if not status:
raise Exception(f"Failed to parse {file_path}.\n{result}")
-
- metadata, text = result
+
+ metadata, text = result
metadata["media"] = [media.lower() for media in metadata["media"]]
@@ -100,10 +99,15 @@ def parse_markdown_file(self, file_path):
if metadata.get("hashtags")
else {}
)
- markdown_content = markdown(text.strip())
- plain_content = BeautifulSoup(markdown_content, "html.parser").get_text(
- separator="\n"
- )
+
+ image_pattern = re.compile(r"!\[(.*?)\]\((.*?)\)")
+ images = image_pattern.findall(text)
+ plain_content = re.sub(image_pattern, "", text).strip()
+
+ metadata["images"] = [
+ {"url": image[1], "alt_text": image[0]} for image in images
+ ]
+
return plain_content, metadata
def process_markdown_file(self, file_path, processed_files):
diff --git a/requirements.txt b/requirements.txt
index 9cc0bbd..b8340b6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,6 @@
aiofiles==23.2.1
atproto==0.0.46
beautifulsoup4==4.12.3
-Markdown==3.6
Mastodon.py==1.8.1
matrix-nio==0.24.0
Pillow==10.3.0