예제 #1
0
    def show_results(self, search_value=''):
        # TODO: paging?
        self.pages_names = []
        self.search_limit = mw.get_setting('mediawiker_search_results_count')
        if search_value:
            self.search_result = self.do_search(search_value)
        if self.search_result:
            for i in range(self.search_limit):
                try:
                    page_data = self.search_result.next()
                    self.pages_names.append([page_data['title'], page_data['snippet']])
                except:
                    pass
            te = ''
            search_number = 1
            for pa in self.pages_names:
                te += '### %s. %s\n* [%s](%s)\n\n%s\n\n' % (search_number, pa[0], pa[0], mw.get_page_url(pa[0]), self.antispan(pa[1]))
                search_number += 1

            if te:
                self.view = sublime.active_window().new_file()
                syntax_file = mw.get_setting('mediawiki_search_syntax', 'Packages/Markdown/Markdown.tmLanguage')
                self.view.set_syntax_file(syntax_file)
                self.view.set_name('Wiki search results: %s' % search_value)
                self.view.run_command('mediawiker_insert_text', {'position': 0, 'text': te})
            elif search_value:
                sublime.message_dialog('No results for: %s' % search_value)
예제 #2
0
 def run(self):
     self.SNIPPET_CHAR = mw.get_setting('snippet_char')
     self.options = [el for el in mw.get_setting('panel', []) if (not el.get('online', True) or el.get('online', True) != mw.get_setting('offline_mode'))]
     if self.options:
         office_panel_list = ['%s' % val['caption'] if val['type'] != 'snippet' else '%s %s' % (
             self.SNIPPET_CHAR, val['caption']) for val in self.options]
         self.window.show_quick_panel(office_panel_list, self.on_done)
예제 #3
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        if self.category_path:
            category_root = mw.get_category(self.get_category_current())[1]
        else:
            category_root = mw.get_category(mw.get_setting('category_root'))[1]
        sublime.active_window().show_input_panel('Wiki root category:', category_root, self.show_list, None, None)
예제 #4
0
    def on_query_completions(self, view, prefix, locations):
        if mw.props.get_view_setting(view, 'is_here') and not mw.props.get_setting('offline_mode'):
            view = sublime.active_window().active_view()

            # internal links completions
            cursor_position = locations[0]  # view.sel()[0].begin()
            line_region = view.line(view.sel()[0])
            line_before_position = view.substr(sublime.Region(line_region.a, cursor_position))
            internal_link = ''
            if line_before_position.rfind('[[') > line_before_position.rfind(']]'):
                internal_link = line_before_position[line_before_position.rfind('[[') + 2:]

            if mw.api.INTERNAL_LINK_SPLITTER in internal_link:
                # cursor at custom url text zone..
                return []

            completions = []
            if internal_link:
                word_cursor_min_len = mw.get_setting('page_prefix_min_length', 3)
                ns_text = None
                ns_text_number = None

                if mw.api.NAMESPACE_SPLITTER in internal_link:
                    ns_text, internal_link = internal_link.split(mw.api.NAMESPACE_SPLITTER)

                if len(internal_link) >= word_cursor_min_len:
                    namespaces_search = [ns.strip() for ns in mw.get_setting('search_namespaces').split(',')]
                    if ns_text:
                        ns_text_number = mw.api.call('get_namespace_number', name=ns_text)

                    # TODO: recheck completions

                    pages = []
                    for ns in namespaces_search:
                        if not ns_text or ns_text_number and int(ns_text_number) == int(ns):
                            pages = mw.api.call('get_pages', prefix=internal_link, namespace=ns)
                            for p in pages:
                                # name - full page name with namespace
                                # page_title - title of the page wo namespace
                                # For (Main) namespace, shows [page_title (Main)], makes [[page_title]]
                                # For Image, Category namespaces, shows [page_title namespace], makes [[name]]
                                # For other namespace, shows [page_title namespace], makes [[name|page_title]]
                                if int(ns):
                                    ns_name = mw.api.page_attr(p, 'namespace_name')
                                    page_name = mw.api.page_attr(p, 'name') if not mw.api.is_equal_ns(ns_text, ns_name) else mw.api.page_attr(p, 'page_title')
                                    if int(ns) in (mw.api.CATEGORY_NAMESPACE, mw.api.IMAGE_NAMESPACE):
                                        page_insert = page_name
                                    else:
                                        page_insert = '%s|%s' % (page_name, mw.api.page_attr(p, 'page_title'))
                                else:
                                    ns_name = '(Main)'
                                    page_insert = mw.api.page_attr(p, 'page_title')
                                page_show = '%s\t%s' % (mw.api.page_attr(p, 'page_title'), ns_name)
                                completions.append((page_show, page_insert))

            return completions
        return []
예제 #5
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        text = self.view.substr(sublime.Region(0, self.view.size()))
        # site = mw.get_setting('site').get(mw.get_view_site())
        site = mw.conman.get_site()

        page_css = mw.api.call('get_page', title='MediaWiki:Common.css')
        text_css = mw.api.page_get_text(page_css)
        if text_css:
            common_css = '''
            <style type="text/css">
            %s
            </style>
            ''' % text_css
        else:
            common_css = ''

        host = site['host']
        path = site['path']
        head = '\n'.join(site['preview_custom_head'] or mw.get_setting('preview_head'))
        lang = mw.get_setting('preview_lang')
        self.page_id = '%s: %s' % (host, mw.get_title())
        self.preview_file = mw.from_package('%s_preview_file.html' % mw.PML, name='User', posix=False, is_abs=True)
        site_http = 'https' if site['https'] else 'http'

        html_header_lines = [
            '<!DOCTYPE html>',
            '<html>',
            '<head>',
            '%(head)s',
            '%(common_css)s'
            '</head>',
            '<body style="margin:20px;">'
        ]

        geshi_css = self.get_geshi_langs()
        head_tpl = Template(head)
        head_str = head_tpl.render(http=site_http, host=host, path=path, lang=lang, geshi_css=geshi_css)
        html_header = '\n'.join(html_header_lines) % {'head': head_str, 'common_css': common_css}
        html_footer = '</body></html>'

        html = mw.api.call('get_parse_result', text=text, title=mw.get_title())
        html = html.replace('"//', '"%s://' % site_http)  # internal links: images,..
        html = html.replace('"/', '"%s://%s/' % (site_http, host))  # internal local links: images,..

        page_id_old = self.get_page_id()
        page = self.generate_preview(html_header, html, html_footer)
        if self.page_id != page_id_old or mw.props.get_view_setting(self.view, 'autoreload') == 0:
            webbrowser.open('file:///%s' % page)
예제 #6
0
    def drawtable(self, table_list):
        ''' draw wiki table '''
        TBL_START = '{|'
        TBL_STOP = '|}'
        TBL_ROW_START = '|-'
        CELL_FIRST_DELIM = '|'
        CELL_DELIM = '||'
        CELL_HEAD_FIRST_DELIM = '!'
        CELL_HEAD_DELIM = '!!'
        REPLACE_STR = ':::'

        text_wikitable = ''
        table_properties = ' '.join(['%s="%s"' % (prop, value) for prop, value in mw.get_setting('mediawiker_wikitable_properties', {}).items()])

        need_header = table_list[0][0]['is_header']
        is_first_line = True
        for row in table_list:
            if need_header or is_first_line:
                text_wikitable += '%s\n%s' % (TBL_ROW_START, CELL_HEAD_FIRST_DELIM)
                text_wikitable += self.getrow(CELL_HEAD_DELIM, row)
                is_first_line = False
                need_header = False
            else:
                text_wikitable += '\n%s\n%s' % (TBL_ROW_START, CELL_FIRST_DELIM)
                text_wikitable += self.getrow(CELL_DELIM, row)
                text_wikitable = text_wikitable.replace(REPLACE_STR, '|')

        return '%s %s\n%s\n%s' % (TBL_START, table_properties, text_wikitable, TBL_STOP)
예제 #7
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        title = mw.get_title()
        view_text = self.view.substr(sublime.Region(0, self.view.size()))

        page = mw.api.call('get_page', title=title)
        text = mw.api.page_get_text(page)

        if not text:
            # Uh, well, what if it does exist, but it is empty?
            msg = 'Wiki page %s does not exists.' % (title,)
            mw.status_message(msg)
        else:
            new_lines = view_text.splitlines(True)
            old_lines = text.splitlines(True)
            diff_lines = difflib.unified_diff(old_lines, new_lines, fromfile="Server revision", tofile="Buffer view")
            diff_text = ''.join(diff_lines)
            if not diff_text:
                mw.status_message('Page versions has no differencies')
            else:
                syntax_filename = 'Diff.sublime-syntax' if pythonver >= 3 else 'Diff.tmLanguage'
                syntax = mw.from_package(syntax_filename, name='Diff')
                mw.status_message(diff_text, panel_name='Show differences', syntax=syntax, new=True)
예제 #8
0
    def get_template_params(self, text):
        site_active = mw.get_view_site()
        site = mw.get_setting('site').get(site_active)
        is_wikia = site.get('is_wikia', False)
        if is_wikia:
            infobox = mw.WikiaInfoboxParser()
            infobox.feed(text)
            params_list = infobox.get_params_list()
            if params_list:
                return ''.join(['|%s\n' % p for p in params_list])

        params_list = []
        # ex: {{{title|{{PAGENAME}}}}}
        pattern = r'(\{{3}.*?\}{3,})'
        parameters = re.findall(pattern, text)
        for param in parameters:
            if param.startswith('{{{'):
                param = param[3:]
            if param.endswith('}}}'):
                param = param[:-3]
            # cut non-param }} from "if" tags, etc..
            # ex: {{#if: ... {{{data2|}}}}}
            close_brackets_diff = param.count('}') - param.count('{')
            if close_brackets_diff > 0:
                param = param[:-close_brackets_diff]
            # default value or not..
            param = param.replace('|', '=') if '|' in param else '%s=' % param
            if param not in params_list:
                params_list.append(param)
        return ''.join(['|%s\n' % p for p in params_list])
예제 #9
0
    def show_results(self, search_value=''):
        # TODO: paging?
        if search_value:
            search_result = self.do_search(search_value)

        if search_result:

            text = ''
            while True:
                try:
                    hit = search_result.next()
                    if hit:
                        text += self.get_block(hit)
                except StopIteration:
                    break

            if text:
                self.view = sublime.active_window().new_file()
                # TODO: view set attrs in utils..
                syntax_file = mw.get_setting('syntax')
                self.view.set_syntax_file(syntax_file)
                self.view.set_name('Wiki search results: %s' % search_value)
                self.view.run_command(mw.cmd('insert_text'), {'position': 0, 'text': text})
            elif search_value:
                sublime.message_dialog('No results for: %s' % search_value)
예제 #10
0
 def get_colapse_headers(self, headers):
     if headers:
         level = headers[0].level
         gutter_png = ''
         if mw.get_setting('show_gutters') and pythonver >= 3:
             gutter_png = mw.from_package('img', 'gutter_h%s.png' % level)
         self.view.add_regions('h_%s' % level, [r.region for r in headers], 'comment', gutter_png, self.DRAW_TYPE)
예제 #11
0
def on_hover_tag(view, point):

    def on_navigate(link):
        if link.startswith('fold'):
            for tag in tags:
                if tag.region.contains(point):
                    tag.fold()
                    return
        elif link.startswith('unfold'):
            for tag in tags:
                if tag.region.contains(point):
                    tag.unfold()
                    return

    popup_flags = get_popup_flags(view)
    if popup_flags is None:
        return

    fold_tags = mw.get_setting("fold_tags")

    p = par.Parser(view)
    p.register_all(
        par.Comment, par.TemplateAttribute, par.Template, par.Link, par.Pre,
        par.Source
    )

    for tag in fold_tags:
        p.register_dynamic(tag)

    if not p.parse():
        return

    tags = p.pres + p.sources
    for tag in fold_tags:
        tags_list = p.elist_by_name(tag)
        if tags_list:
            tags += tags_list

    tags.sort(key=lambda x: x.region.a, reverse=True)
    for tag in tags:
        if tag.region.contains(point):

            content = [
                html.h(4, 'Tag "%s"' % tag.title.title()),
                html.join(
                    html.link('fold', 'Fold'),
                    html.link('unfold', 'Unfold'),
                    char=html.span('|', css_class='wide')
                )
            ]
            content_html = html.build(content)

            view.show_popup(
                content=content_html,
                location=point,
                flags=popup_flags,
                on_navigate=on_navigate
            )
            return True
    return False
예제 #12
0
 def run(self):
     # self.site_active = mw.get_setting('mediawiki_site_active')
     self.site_active = mw.get_view_site()
     sites = mw.get_setting('mediawiki_site')
     # self.site_keys = map(self.is_checked, list(sites.keys()))
     self.site_keys = [self.is_checked(x) for x in sorted(sites.keys(), key=str.lower)]
     sublime.set_timeout(lambda: self.window.show_quick_panel(self.site_keys, self.on_done), 1)
예제 #13
0
 def get_user_css(self):
     css_user = mw.get_setting('css_html', {})
     if css_user:
         for key in css_user.keys():
             for tag in css_user[key].keys():
                 if key in self.css_rules:
                     if tag in self.css_rules[key]:
                         self.css_rules[key][tag] = css_user[key][tag]
예제 #14
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        search_pre = ''
        selection = self.view.sel()
        search_pre = self.view.substr(selection[0]).strip() if selection and selection[0] else ''
        sublime.active_window().show_input_panel('Wiki search:', search_pre, self.show_results, None, None)
예제 #15
0
    def run(self, edit, version='sublime'):

        if pythonver < 3 and version == 'sublime':
            if sublime.ok_cancel_dialog('For Sublime Text 2 version, changelog will be opened in browser'):
                version = 'browser'
            else:
                return

        self.MARKED = mw.get_setting('config_icon_checked')
        self.UNMARKED = mw.get_setting('config_icon_unchecked')
        self.RADIO_MARKED = mw.get_setting('config_icon_radio_checked')
        self.RADIO_UNMARKED = mw.get_setting('config_icon_radio_unchecked')
        self.EDIT_ICON = mw.get_setting('config_icon_edit')
        self.BACK_ICON = mw.get_setting('config_icon_back')
        self.LIST_ICON = mw.get_setting('config_icon_unnumbered_list')

        self.html = mw_html.MwHtmlAdv(html_id='mediawiker_changelog', user_css=False)
        self.set_css()
        # self.html.debug = True

        if pythonver >= 3:
            with open(mw.from_package('Changelog.mediawiki', posix=False, is_abs=True), 'r', encoding='utf-8') as cl:
                log = cl.read()
        else:
            with open(mw.from_package('Changelog.mediawiki', posix=False, is_abs=True), 'r') as cl:
                log = cl.read().decode('utf-8')

        self.process_h2_regions(log, 2, version)
예제 #16
0
 def run(self, storage_name='pagelist'):
     site_name_active = mw.get_view_site()
     pagelist = mw.get_setting(storage_name, {})
     self.my_pages = pagelist.get(site_name_active, [])
     if self.my_pages:
         self.my_pages.reverse()
         sublime.set_timeout(lambda: self.window.show_quick_panel(self.my_pages, self.on_done), 1)
     else:
         mw.status_message('List of pages for wiki "%s" is empty.' % (site_name_active))
예제 #17
0
 def getrow(self, delimiter, rowlist=None):
     if rowlist is None:
         rowlist = []
     cell_properties = ' '.join(['%s="%s"' % (prop, value) for prop, value in mw.get_setting('mediawiker_wikitable_cell_properties', {}).items()])
     cell_properties = '%s | ' % cell_properties if cell_properties else ''
     try:
         return delimiter.join(' %s%s ' % (cell_properties, cell['cell_data'].strip()) for cell in rowlist)
     except Exception as e:
         mw.status_message('Error in data: %s' % e)
예제 #18
0
    def run(self):
        if mw.get_setting('offline_mode'):
            return

        url = mw.get_page_url()
        if url:
            webbrowser.open(url)
        else:
            mw.status_message('Can\'t open page with empty title')
            return
예제 #19
0
    def run(self, url):
        if mw.get_setting('offline_mode'):
            return

        if url:
            url = mw.strunquote(url)
            sublime.set_timeout(lambda: self.window.run_command(mw.cmd('page'), {
                'action': mw.cmd('show_page'),
                'action_params': {'title': self.proto_replacer(url)}
            }), 1)
예제 #20
0
def get_popup_flags(view):
    if mw.props.get_view_setting(view, 'popups_off'):
        return None
    popup_type = mw.get_setting('popup_type')
    if popup_type == 'manual':
        return 0
    elif popup_type == 'auto':
        return sublime.HIDE_ON_MOUSE_MOVE_AWAY
    elif popup_type == 'off':
        return None
    return sublime.HIDE_ON_MOUSE_MOVE_AWAY
예제 #21
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        title = mw.get_title()
        self.mw_get_page_backlinks(title)

        if self.links:
            sublime.active_window().show_quick_panel(self.links, self.on_done)
        else:
            mw.status_message('Unable to find links to this page')
예제 #22
0
 def run(self, storage_name='mediawiker_pagelist'):
     # site_name_active = mw.get_setting('mediawiki_site_active')
     site_name_active = mw.get_view_site()
     mediawiker_pagelist = mw.get_setting(storage_name, {})
     self.my_pages = mediawiker_pagelist.get(site_name_active, [])
     if self.my_pages:
         self.my_pages.reverse()
         # error 'Quick panel unavailable' fix with timeout..
         sublime.set_timeout(lambda: self.window.show_quick_panel(self.my_pages, self.on_done), 1)
     else:
         mw.status_message('List of pages for wiki "%s" is empty.' % (site_name_active))
예제 #23
0
    def run(self):
        if mw.get_setting('offline_mode'):
            return

        ignore_read = not mw.get_setting('notifications_show_all')
        read_sign = mw.get_setting('notifications_read_sign')
        self.msgs = mw.api.get_notifications_list(ignore_read=ignore_read)
        self.msgs = sorted(self.msgs, key=lambda k: k['read'])
        n_list = ['All in browser']
        for m in self.msgs:
            line = '%s, %s: %s (%s)%s' % (
                m['title'],
                m['agent'],
                m['timestamp'],
                m['type'],
                ' %s' % read_sign if m['read'] else ''
            )
            n_list.append(line)

        self.window.show_quick_panel(n_list, self.on_done)
예제 #24
0
    def run(self, edit):
        notifications_type = mw.get_setting('mediawiki_notifications_show_all', True)
        self.read_sign = mw.get_setting('mediawiki_notifications_read_sign', ' [+]')
        sitecon = mw.get_connect()
        ns = sitecon.notifications()
        self.msgs = []
        if ns:
            if isinstance(ns, dict):
                for n in ns.keys():
                    msg = ns.get(n, {})
                    msg_read = msg.get('read', '')
                    if notifications_type or not msg_read:
                        self.msgs.append(self._get_data(msg))
            elif isinstance(ns, list):
                for msg in ns:
                    msg_read = msg.get('read', '')
                    if notifications_type or not msg_read:
                        self.msgs.append(self._get_data(msg))

        self.msgs = sorted(self.msgs, key=lambda k: k['read'])
        n_list = ['All in browser'] + ['%s, %s: %s (%s)%s' % (m['title'], m['agent'], m['timestamp'], m['type'], m['read']) for m in self.msgs]
        sublime.active_window().show_quick_panel(n_list, self.on_done)
예제 #25
0
    def run(self, edit):
        self.delimiter = mw.get_setting('mediawiker_csvtable_delimiter', '|')
        table_header = '{|'
        table_footer = '|}'
        table_properties = ' '.join(['%s="%s"' % (prop, value) for prop, value in mw.get_setting('mediawiker_wikitable_properties', {}).items()])
        cell_properties = ' '.join(['%s="%s"' % (prop, value) for prop, value in mw.get_setting('mediawiker_wikitable_cell_properties', {}).items()])
        if cell_properties:
            cell_properties = ' %s | ' % cell_properties

        for region in self.view.sel():
            table_data_dic_tmp = []
            table_data = ''
            # table_data_dic_tmp = map(self.get_table_data, self.view.substr(region).split('\n'))
            table_data_dic_tmp = [self.get_table_data(x) for x in self.view.substr(region).split('\n')]

            # verify and fix columns count in rows
            if table_data_dic_tmp:
                cols_cnt = len(max(table_data_dic_tmp, key=len))
                for row in table_data_dic_tmp:
                    if row:
                        while cols_cnt - len(row):
                            row.append('')

                for row in table_data_dic_tmp:
                    if row:
                        if table_data:
                            table_data += '\n|-\n'
                            column_separator = '||'
                        else:
                            table_data += '|-\n'
                            column_separator = '!!'

                        for col in row:
                            col_sep = column_separator if row.index(col) else column_separator[0]
                            table_data += '%s%s%s ' % (col_sep, cell_properties, col)

                self.view.replace(edit, region, '%s %s\n%s\n%s' % (table_header, table_properties, table_data, table_footer))
예제 #26
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        self.item = None

        red_link_icon = mw.get_setting('red_link_icon')
        page = mw.api.get_page(mw.get_title())
        linksgen = mw.api.get_page_links(page, generator=True)

        self.p = par.Parser(self.view)
        self.p.register_all(par.Comment, par.Pre, par.Source, par.Link, par.TemplateAttribute, par.Template)
        if not self.p.parse():
            return

        self.menu_items = ['%s %s' % (mw.api.page_attr(v, 'name'), red_link_icon if not v.exists else '  ') for v in linksgen]
        self.find_items = [v.strip_namespace(mw.api.page_attr(v, 'name')) for v in linksgen]
        self.open_items = [mw.api.page_attr(v, 'name') for v in linksgen]
        self.ns_items = [mw.api.page_attr(v, 'namespace') for v in linksgen]

        if self.menu_items:
            sublime.set_timeout(lambda: self.view.window().show_quick_panel(self.menu_items, self.on_select), 1)
        else:
            mw.status_message('Internal links was not found.')
예제 #27
0
    def on_activated(self, view):
        current_syntax = mw.props.get_view_setting(view, 'syntax', plugin=False)

        # TODO: move method to check mediawiker view to mwutils
        if (current_syntax is not None and
                current_syntax.startswith(mw.from_package('Mediawiki')) and
                current_syntax.endswith(('.tmLanguage', '.sublime-syntax'))):

            # Mediawiki mode
            mw.props.set_view_setting(view, 'is_here', True)

            if not view.file_name():
                mw.props.set_view_setting(view, 'wiki_instead_editor', mw.get_setting('wiki_instead_editor'))
            else:
                mw.props.set_view_setting(view, 'wiki_instead_editor', False)

            mw.props.set_view_setting(view, 'site', mw.get_view_site())
예제 #28
0
    def run(self, edit):
        if mw.get_setting('offline_mode'):
            return

        self.item = None
        page = mw.api.get_page(mw.get_title())
        linksgen = mw.api.get_page_extlinks(page)

        self.p = par.Parser(self.view)
        self.p.register_all(par.Comment, par.Pre, par.Source, par.Link, par.ExternalLink)
        if not self.p.parse():
            return

        self.items_menu = [self.link_for_menu(l) for l in linksgen]
        self.items_find = [l.split('#')[0] for l in linksgen]
        self.items_open = [l for l in linksgen]

        if self.items_menu:
            sublime.set_timeout(lambda: self.view.window().show_quick_panel(self.items_menu, self.on_select), 1)
        else:
            mw.status_message('No external links was found.')
예제 #29
0
    def mw_get_page_backlinks(self, site, title):
        self.links = []
        links_limit = mw.get_setting("mediawiki_linkstopage_limit", 5)
        page = site.Pages[title]

        # backlinks to page
        linksgen = page.backlinks(limit=links_limit)
        if linksgen:
            while True:
                try:
                    prop = linksgen.next()
                    self.links.append(prop.name)
                except StopIteration:
                    break

        # pages, transcludes this
        linksgen = page.embeddedin(limit=links_limit)
        if linksgen:
            while True:
                try:
                    prop = linksgen.next()
                    self.links.append(prop.name)
                except StopIteration:
                    break
예제 #30
0
    def mw_get_page_backlinks(self, title):
        self.links = []
        links_limit = mw.get_setting('linkstopage_limit')
        page = mw.api.get_page(title)

        # backlinks to page
        linksgen = mw.api.get_page_backlinks(page, links_limit)
        if linksgen:
            while True:
                try:
                    prop = linksgen.next()
                    self.links.append(mw.api.page_attr(prop, 'name'))
                except StopIteration:
                    break

        # pages, transcludes this
        linksgen = mw.api.get_page_embeddedin(page, links_limit)
        if linksgen:
            while True:
                try:
                    prop = linksgen.next()
                    self.links.append(mw.api.page_attr(prop, 'name'))
                except StopIteration:
                    break