wiki-postbot/wiki_postbot/formats/wiki.py

17 lines
426 B
Python
Raw Normal View History

"""
Helper functions for dealing with wiki syntax as well as format
output posts triggered by :class:`.action.WikiLink`
"""
2022-10-17 01:35:49 +00:00
from dataclasses import dataclass
import wikitextparser as wtp
2022-10-17 01:35:49 +00:00
@dataclass
class WikiPage:
title:str
source:str
content:wtp.WikiText
@classmethod
def from_source(self, title, source) -> 'WikiPage':
content = wtp.parse(source)
return WikiPage(title, source, content)