fix
This commit is contained in:
+11
-11
@@ -615,11 +615,17 @@ def insert_link_naturally(summary, source_name, source_url):
|
||||
link_pattern = f'<a href="{source_url}">{source_name}</a>'
|
||||
|
||||
words = sentence.split()
|
||||
if len(words) < 3:
|
||||
new_sentence = f"{sentence} according to {link_pattern}."
|
||||
if len(words) < 5: # Ensure enough words for natural insertion
|
||||
new_sentence = f"{sentence.rstrip('.')} according to {link_pattern}."
|
||||
else:
|
||||
split_point = random.randint(1, len(words)-2)
|
||||
new_sentence = f"{' '.join(words[:split_point])}, according to {link_pattern}, {' '.join(words[split_point:])}"
|
||||
split_point = random.randint(2, len(words)-3) # Split further into the sentence
|
||||
# Remove trailing punctuation from the first part and ensure proper grammar
|
||||
first_part = ' '.join(words[:split_point]).rstrip(',')
|
||||
second_part = ' '.join(words[split_point:]).lstrip(',')
|
||||
new_sentence = f"{first_part} according to {link_pattern} {second_part}"
|
||||
# Ensure the sentence ends with a period
|
||||
if not new_sentence.endswith('.'):
|
||||
new_sentence += '.'
|
||||
|
||||
sentences[sentence_idx] = new_sentence
|
||||
new_para = ' '.join(sentences)
|
||||
@@ -749,13 +755,7 @@ def post_to_wp(post_data, category, link, author, image_url, original_source, im
|
||||
content = "Content unavailable. Check the original source for details."
|
||||
formatted_content = "\n".join(f"<p>{para}</p>" for para in content.split('\n') if para.strip())
|
||||
|
||||
if image_url and image_source:
|
||||
attribution = f"Image Source: {image_source}"
|
||||
if page_url and uploader:
|
||||
attribution = f'Image Source: <a href="{page_url}">{image_source}</a> by {uploader}'
|
||||
elif page_url:
|
||||
attribution = f'Image Source: <a href="{page_url}">{image_source}</a>'
|
||||
formatted_content += f"\n<p>{attribution}</p>"
|
||||
# Removed the block that appends image attribution to the content
|
||||
|
||||
author_id_map = {
|
||||
"owenjohnson": 10,
|
||||
|
||||
Reference in New Issue
Block a user