Skip to content

Issue with processor Use in Obsidian-to-Hugo Conversion #19

@kl2111

Description

@kl2111

Hello, I'm facing challenges understanding the usage of processor. I have a list of tuples named error_description in my Obsidian double-links, which I'd like to keep unaltered during the Obsidian-to-Hugo conversion. I am attempting to use processors to replace [[error_description]] with (error_description) during this process.

However, I've noticed that the code seems to go directly to the else block, printing Debug: No match for [[error_description]]). I confirmed that [[error_description]] does indeed exist in the original text. Below is the snippet of code in question:

def process_file(file_contents: str) -> str:
    processed_contents = file_contents
    print(f"Debug: error_descriptions = {error_descriptions}")
    for error_description in error_descriptions:
        search_str = f'[[error_description]])'
        print(f"Debug: Looking for {search_str}")
        if search_str in processed_contents:
            print(f"Debug: Replacing {search_str}")
            processed_contents = processed_contents.replace(search_str, f'({error_description})')
        else:
            print(f"Debug: No match for {search_str}")
    print(f"Debug: Final file contents: {processed_contents[:100]}")  # Output the first 100 chars after modification

# Build and Run ObsidianToHugo
obsidian_to_hugo = ObsidianToHugo(
    obsidian_vault_dir=obsidian_vault_dir_path,
    hugo_content_dir=hugo_content_dir_path,
    processors=[process_file],
)
obsidian_to_hugo.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions