Exemple #1
0
def open_style(html, args, tumd):
    global used_style
    if used_style:
        print('ERROR: You can only use one style context.')
        raise SystemExit
    if len(tumd.context) > 2:
        print('ERROR: You can only use a style context at the beginning of the tumd file.')
        print(tumd.context)
        raise SystemExit
    html.add('<style>')
    used_style = True
    push([html])
Exemple #2
0
 def write_sidenav(args):
     args[0].html.add('<nav id="sidenav">')
     push([args[0].html])
     for heading in args[0].headings:
         sidenav_level = ''
         #           for i in range(1, heading[2]):
         #               sidenav_level += '<div class="sidenav-level"></div>'
         args[0].html.add(sidenav_level + '<a href="#' + heading[0] +
                          '" style="padding-left:' + str(12 *
                                                         (heading[2])) +
                          'px;">' + heading[1] + '</a>')
     pop([args[0].html])
     args[0].html.add('</nav>')
     args[0].html.add('<div id="sidenav-activator"></div>')
     return ''
Exemple #3
0
def add_li(html, line_data):
    global list_first_element
    line = line_data[0]
    blank_lines = line_data[1] > 1
    if list_first_element:
        html.add('<li>' + line)
        push([html])
        list_first_element = False
        return
    if blank_lines:
        pop([html])
        html.add('</li>')
        html.add('<li>' + line)
        push([html])
    else:
        html.add(line)
Exemple #4
0
def print_subfolders(args):
    html = args[0]
    content = args[1]
    maindir = os.path.dirname(os.path.realpath(content.tumd.infile.name))
    dirs = get_immediate_subdirectories(maindir)
    dirs.sort()
    articles = []
    for directory in dirs:
        try:
            with open(maindir + '/' + directory + '/index.tumd',
                      'r') as file_reader:
                line = file_reader.readline().rstrip()
                if line == 'article':
                    content_dict = get_tags(file_reader, line)
                    content_dict['Directory'] = directory
                    articles.append(content_dict)
        except:
            pass
    if len(articles) > 0:
        html.add('<h1 class="section-head">Articles</h1>')
    for article in articles:
        html.add('<div class="article-box">')
        push([html])
        html.add('<h2 class="article-box-text"><a href="' +
                 article['Directory'] + '">' + article['Title'] +
                 '</a></h2><br>')
        html.add('<h4 class="article-box-text">by <a href="' +
                 author_name(article['Author']) + '">' + article['Author'] +
                 '</a></h4><br>')
        html.add('<span style="font-size: 1.25em">' + article['Tagline'] +
                 '</span>')
        html.add('<a href="' + article['Directory'] +
                 '" class="article-box-link"></a>')
        pop([html])
        html.add('</div>')
    return ''
Exemple #5
0
def open_aside(html, args, tumd):
    html.add('<div class="aside" ' + args + '>')
    push([html])
Exemple #6
0
def open_spoiler(html, args, tumd):
    html.add('<div class="spoiler">')
    push([html])
    html.add('<div class="content">')
Exemple #7
0
def open_ol(html, args, tumd):
    global list_first_element
    html.add('<ol>')
    push([html])
    list_first_element = True