Hello if anyone knows of a way to get python-markdown to behave in the way I'd like, or of an alternative way to do it, I'd love some help! My use case is I'm converting .md files made with Obsidian into html files. Obsidian has tags that are a pound sign followed by the tag (so like "#TagName"). When the tag is the first item on a line the pound sign is confused for a heading, even though there is no space after it.
Is there a way that I can avoid this so it only reads it as a heading if there is a space between the pound and the next word? I'm even considering some kind of find/replace logic so I can swap it out with like a link to a page that lists all the pages with that tag or something that gets run before the markdown to html conversion.
Edit:
The solution I'm going for is a regex find/replace. Currently the string pattern looks like "#[^\s#][^\s" + string.punctuation + "#]*" which can find tags but ignores headers. Since the ultimate goal is to have the tags link to a tag p
Hi all. I have a little problem and don't know how to solve. A CLI program in Python is broken since Python 3.12. It was working in Python 3.11. The reason is, that Python 3.12 changed how subclassing of a pathlib.Path works (basically fixed an issue), which now breaks a workaround.
Hello! I'm attempting to follow some tutorials on unit testing with Python. One of them is a video tutorial Unit Tests in Python on the Socratica channel. Everyone in the comments seems to be making out just fine, and I’m following the instructor’s directions to the letter, yet I get a different result. It’s driving me mad lol.
In the video, the instructor creates two text files, one called circles.py in which she defines a function circle_area(r), and another called test_circles.py in which she writes some unit tests. In my attempt to follow along, I've ended up with two files structured like so:
from math import pi
def circle_area(r):
return pi*(r**2)
# Test function
radii = [2, 0, -3, 2 + 5j, True, "radius"]
message = "Area of circles with r = {radius} is {area}."
for r in radii:
A = circle_area(r)
print(mes
Edit: The key was using msys2. After installing Gtk3 and PyGObject following the PyGObject guide for msys2 everything worked fine. Packaging with PyInstaller and nuitka was fine.
I've been developing an image halftoning app for a while using GTK on Linux, thinking GTK is cross platform, and delaying testing it on Windows for quite some time.
Today I decided to finally install Windows 10 (for the first time in more than a decade) on a separate machine and see what works and what does not.
For the past few hours I've been through hell trying to get GTK3 to work. I've followed multiple guides, none of which worked, including wingtk.
Furthermore, even if I successfully compile (or install) GTK, would it be possible to package it all up using something like PyInstaller or nuitka.
At this point I'm thinking of keeping the functions and writing a whole ne
I won't know if this script works until I run it and see the errors but the comments won't start to generate until after all the posts so I can't debug that part until I've already created too much content.
python
import sqlite3
import requests
from pythorhead import Lemmy
import schedule
import time
import logging
from config import *
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s %(message)s",
handlers=[logging.FileHandler("debug.log"), logging.StreamHandler()],
)
def initialize_database():
conn = sqlite3.connect(DB_FILE)
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS posts (
github_url TEXT PRIMARY KEY,
lemmy_post_id INTEGER,
lemmy_post_name TEXT,
lemmy_post_body TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS comments (
github_comment_id INTEGER PRIMARY KEY,
lemmy_comment_id INTEGE