So, I'm trying to write a really quick plugin which will autolink to our github issues from the wiki. (sorta like github does itself.) That worked out almost perfectly with this little snippet:
import re
from realms.modules.wiki.models import Wiki
@Wiki.after('get_page')
def wiki_get_page(name, sha=None, rv=None, **kwargs):
rv['data'] = re.sub(r'(?<![\w\d])(#(\d{3,4}))(?![\w\d])',
r'[\1](https://github.com/Flexget/Flexget/issues/\2)',
rv['data'])
The only issue is that when you go to edit the page, the replaced markdown will be shown in the edit view, and thus saved the long way back to the wiki.
Is there a better way to go about this at the moment? If not, can we make somewhere better to hook for viewing only?
So, I'm trying to write a really quick plugin which will autolink to our github issues from the wiki. (sorta like github does itself.) That worked out almost perfectly with this little snippet:
The only issue is that when you go to edit the page, the replaced markdown will be shown in the edit view, and thus saved the long way back to the wiki.
Is there a better way to go about this at the moment? If not, can we make somewhere better to hook for viewing only?