Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin example: move wikilink processing #96

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

weaversam8
Copy link
Contributor

  • This PR uses the pluggy framework mentioned in Thoughts on extensibility #91 to move the "wikilink" parsing functionality to a separate "plugin" that is still housed within the OtterWiki codebase.

  • The wikilink parsing code is unchanged, and was just moved to a WikiLinkPlugin class, which implements the new preprocess_markdown hook.

  • The WikiLinkPlugin is manually registered, but this commit also includes code to automatically discover plugins installed as Python packages if they use the "otterwiki" Setuptools entrypoint. This has yet to be tested, but should work.

  • Tests have been updated.

CC @redimp - what do you think? This should be a really easy/simple hook to start with.

- This commit uses the `pluggy` framework mentioned in redimp#91 to move the
  "wikilink" parsing functionality to a separate "plugin" that is still
  housed within the OtterWiki codebase.

- The wikilink parsing code is unchanged, and was just moved to a
  WikiLinkPlugin class, which implements the new `preprocess_markdown`
  hook.

- The WikiLinkPlugin is manually registered, but this commit also
  includes code to automatically discover plugins installed as Python
  packages if they use the "otterwiki" Setuptools entrypoint. This has
  yet to be tested, but should work.

- Tests have been updated.
@redimp
Copy link
Owner

redimp commented Mar 6, 2024

I'm running out of superlatives. This is brilliant.

preprocess_markdown is a well picked as proof of concept.

TBH: Using preprocessing for handling the wiki links was a workaround, because at this time my approaches to extend mistune were not working as I expected. Happy to see that this somehow became useful. 😅

Still need to understand how pluggy works exactly, but that will be easy with this PR. Will merge as soon as I get the hang of it.

I'll check tomorrow or at the weekend to see what other places there are that are suitable for hooks. I look forward to your suggestions.

@redimp redimp merged commit 0d6c14f into redimp:main Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants