Esempio n. 1
0
    def __init__ (self, page, config):
        self.page = page
        self.config = config
        self.error_template = u"<B>{error}</B>"

        # Массив строк, которые надо добавить в заголовок страницы
        self.__headers = []

        # Команды, обрабатывает парсер.
        # Формат команд: (:name params... :) content... (:nameend:)
        # Ключ - имя команды, значение - экземпляр класса команды
        self.commands = {}

        self.italicized = FontsFactory.makeItalic (self)
        self.bolded = FontsFactory.makeBold (self)
        self.boldItalicized = FontsFactory.makeBoldItalic (self)
        self.underlined = FontsFactory.makeUnderline (self)
        self.strike = FontsFactory.makeStrike (self)
        self.subscript = FontsFactory.makeSubscript (self)
        self.superscript = FontsFactory.makeSuperscript (self)
        self.code = FontsFactory.makeCode (self)
        self.small = FontsFactory.makeSmall(self)
        self.big = FontsFactory.makeBig(self)
        self.headings = HeadingFactory.make(self)
        self.thumb = ThumbnailFactory.make(self)
        self.noformat = NoFormatFactory.make(self)
        self.preformat = PreFormatFactory.make (self)
        self.horline = HorLineFactory.make(self)
        self.link = LinkFactory.make (self)
        self.align = AlignFactory.make(self)
        self.table = TableFactory.make(self)
        self.url = UrlFactory.make (self)
        self.urlImage = UrlImageFactory.make (self)
        self.attaches = AttachFactory.make (self)
        self.attachImages = AttachImagesFactory.make (self)
        self.adhoctokens = AdHocFactory.make(self)
        self.lists = ListFactory.make (self)
        self.lineBreak = LineBreakFactory.make (self)
        self.lineJoin = LineJoinFactory.make (self)
        self.tex = TexFactory.make (self)
        self.command = CommandFactory.make (self)
        self.text = TextFactory.make(self)

        self.listItemMarkup = (self.attaches |
                self.urlImage |
                self.url |
                self.text | 
                self.lineBreak |
                self.lineJoin |
                self.link |
                self.boldItalicized |
                self.bolded |
                self.italicized |
                self.code |
                self.small |
                self.big |
                self.preformat |
                self.noformat |
                self.thumb |
                self.underlined |
                self.strike |
                self.subscript |
                self.superscript |
                self.attaches |
                self.tex |
                self.command
                )


        self.wikiMarkup = (self.attaches |
                self.urlImage |
                self.url |
                self.text | 
                self.lineBreak |
                self.lineJoin |
                self.link |
                self.adhoctokens |
                self.subscript |
                self.superscript |
                self.boldItalicized |
                self.bolded |
                self.italicized |
                self.code |
                self.small |
                self.big |
                self.preformat |
                self.noformat |
                self.thumb |
                self.underlined |
                self.strike |
                self.horline |
                self.align |
                self.lists |
                self.table |
                self.headings |
                self.tex |
                self.command
                )

        # Нотация для ссылок
        self.linkMarkup = (self.attachImages |
                self.urlImage |
                self.text | 
                self.adhoctokens |
                self.subscript |
                self.superscript |
                self.boldItalicized |
                self.bolded |
                self.italicized |
                self.underlined |
                self.small |
                self.big |
                self.strike |
                self.tex |
                self.command |
                self.lineBreak |
                self.lineJoin |
                self.noformat
                )

        # Нотация для заголовков
        self.headingMarkup = (self.attaches |
                self.urlImage |
                self.url |
                self.text | 
                self.lineBreak |
                self.lineJoin |
                self.link |
                self.adhoctokens |
                self.subscript |
                self.superscript |
                self.boldItalicized |
                self.bolded |
                self.italicized |
                self.small |
                self.big |
                self.noformat |
                self.thumb |
                self.underlined |
                self.strike |
                self.horline |
                self.align |
                self.tex |
                self.command
                )
Esempio n. 2
0
    def __init__ (self, page, config):
        self.page = page
        self.config = config
        self.error_template = u"<b>{error}</b>"

        # Dictionary with nonstandard parameters (for plugins for example)
        self.customProps = {}

        # Массив строк, которые надо добавить в заголовок страницы
        self.__headers = []

        # Команды, которые обрабатывает парсер.
        # Формат команд: (:name params... :) content... (:nameend:)
        # Ключ - имя команды, значение - экземпляр класса команды
        self.commands = {}

        self.italicized = FontsFactory.makeItalic (self)
        self.bolded = FontsFactory.makeBold (self)
        self.boldItalicized = FontsFactory.makeBoldItalic (self)
        self.underlined = FontsFactory.makeUnderline (self)
        self.strike = FontsFactory.makeStrike (self)
        self.subscript = FontsFactory.makeSubscript (self)
        self.superscript = FontsFactory.makeSuperscript (self)
        self.quote = QuoteFactory.make (self)
        self.code = FontsFactory.makeCode (self)
        self.mark = FontsFactory.makeMark (self)
        self.small = FontsFactory.makeSmall(self)
        self.big = FontsFactory.makeBig(self)
        self.headings = HeadingFactory.make(self)
        self.thumb = ThumbnailFactory.make(self)
        self.noformat = NoFormatFactory.make(self)
        self.preformat = PreFormatFactory.make (self)
        self.horline = HorLineFactory.make(self)
        self.link = LinkFactory.make (self)
        self.align = AlignFactory.make(self)
        self.table = TableFactory.make(self)
        self.url = UrlFactory.make (self)
        self.urlImage = UrlImageFactory.make (self)
        self.attaches = AttachFactory.make (self)
        self.attachImages = AttachImagesFactory.make (self)
        self.adhoctokens = AdHocFactory.make(self)
        self.lists = ListFactory.make (self)
        self.lineBreak = LineBreakFactory.make (self)
        self.lineJoin = LineJoinFactory.make (self)
        self.command = CommandFactory.make (self)
        self.text = TextFactory.make(self)

        # Common wiki tokens
        self.wikiTokens = [
            self.attaches,
            self.urlImage,
            self.url,
            self.text,
            self.lineBreak,
            self.lineJoin,
            self.link,
            self.adhoctokens,
            self.subscript,
            self.superscript,
            self.boldItalicized,
            self.bolded,
            self.italicized,
            self.code,
            self.mark,
            self.small,
            self.big,
            self.quote,
            self.preformat,
            self.noformat,
            self.thumb,
            self.underlined,
            self.strike,
            self.horline,
            self.align,
            self.lists,
            self.table,
            self.headings,
            self.command,
        ]

        # Tokens for using inside links
        self.linkTokens = [
            self.attachImages,
            self.urlImage,
            self.text,
            self.adhoctokens,
            self.subscript,
            self.superscript,
            self.boldItalicized,
            self.bolded,
            self.italicized,
            self.underlined,
            self.small,
            self.big,
            self.mark,
            self.strike,
            self.command,
            self.lineBreak,
            self.lineJoin,
            self.noformat,
        ]

        # Tokens for using inside headings
        self.headingTokens = [
            self.attaches,
            self.urlImage,
            self.url,
            self.text,
            self.lineBreak,
            self.lineJoin,
            self.link,
            self.adhoctokens,
            self.subscript,
            self.superscript,
            self.boldItalicized,
            self.bolded,
            self.italicized,
            self.small,
            self.big,
            self.mark,
            self.noformat,
            self.thumb,
            self.underlined,
            self.strike,
            self.horline,
            self.align,
            self.command,
        ]

        # Tokens for using inside text
        self.textLevelTokens = [
            self.attaches,
            self.urlImage,
            self.url,
            self.text,
            self.lineBreak,
            self.lineJoin,
            self.link,
            self.adhoctokens,
            self.subscript,
            self.superscript,
            self.boldItalicized,
            self.bolded,
            self.italicized,
            self.code,
            self.mark,
            self.small,
            self.big,
            self.noformat,
            self.thumb,
            self.underlined,
            self.strike,
            self.horline,
            self.command,
        ]

        # Tokens for using inside list items (bullets and numeric)
        self.listItemsTokens = [
            self.attaches,
            self.urlImage,
            self.url,
            self.text,
            self.lineBreak,
            self.lineJoin,
            self.link,
            self.boldItalicized,
            self.bolded,
            self.italicized,
            self.code,
            self.mark,
            self.small,
            self.big,
            self.preformat,
            self.noformat,
            self.thumb,
            self.underlined,
            self.strike,
            self.subscript,
            self.superscript,
            self.quote,
            self.attaches,
            self.command,
        ]

        self._wikiMarkup = None
        self._listItemMarkup = None
        self._linkMarkup = None
        self._headingMarkup = None
        self._textLevelMarkup = None