Example #1
0
def configure_pelican(pelicanobj):
    global render_as_code
    render_as_code = pelicanobj.settings.get('M_MATH_RENDER_AS_CODE', False)
    cache_file = pelicanobj.settings.get('M_MATH_CACHE_FILE', 'm.math.cache')
    if cache_file and os.path.exists(cache_file):
        latex2svgextra.unpickle_cache(cache_file)
    else:
        latex2svgextra.unpickle_cache(None)
Example #2
0
File: math.py Project: mosra/m.css
def register_mcss(mcss_settings, hooks_pre_page, hooks_post_run, **kwargs):
    global default_settings, settings
    settings = copy.deepcopy(default_settings)
    for key in settings.keys():
        if key in mcss_settings: settings[key] = mcss_settings[key]

    if settings['M_MATH_CACHE_FILE']:
        settings['M_MATH_CACHE_FILE'] = os.path.join(settings['INPUT'], settings['M_MATH_CACHE_FILE'])

        if os.path.exists(settings['M_MATH_CACHE_FILE']):
            latex2svgextra.unpickle_cache(settings['M_MATH_CACHE_FILE'])
        else:
            latex2svgextra.unpickle_cache(None)

    hooks_pre_page += [new_page]
    hooks_post_run += [save_cache]

    rst.directives.register_directive('math', Math)
    rst.roles.register_canonical_role('math', math)
Example #3
0
File: math.py Project: almet/m.css
def register_mcss(mcss_settings, hooks_pre_page, hooks_post_run, **kwargs):
    global default_settings, settings
    settings = copy.deepcopy(default_settings)
    for key in settings.keys():
        if key in mcss_settings: settings[key] = mcss_settings[key]

    if settings['M_MATH_CACHE_FILE']:
        settings['M_MATH_CACHE_FILE'] = os.path.join(
            settings['INPUT'], settings['M_MATH_CACHE_FILE'])

        if os.path.exists(settings['M_MATH_CACHE_FILE']):
            latex2svgextra.unpickle_cache(settings['M_MATH_CACHE_FILE'])
        else:
            latex2svgextra.unpickle_cache(None)

    hooks_pre_page += [new_page]
    hooks_post_run += [save_cache]

    rst.directives.register_directive('math', Math)
    rst.roles.register_canonical_role('math', math)
Example #4
0
def register_mcss(mcss_settings, hooks_pre_page, hooks_post_run, **kwargs):
    global default_settings, settings
    settings = copy.deepcopy(default_settings)
    for key in settings.keys():
        if key in mcss_settings: settings[key] = mcss_settings[key]

    if settings['M_MATH_CACHE_FILE']:
        settings['M_MATH_CACHE_FILE'] = os.path.join(
            settings['INPUT'], settings['M_MATH_CACHE_FILE'])

    # Ensure that cache is unpickled again if M_MATH_CACHE_FILE is *not* set --
    # otherwise tests will sporadically fail.
    if settings['M_MATH_CACHE_FILE'] and os.path.exists(
            settings['M_MATH_CACHE_FILE']):
        latex2svgextra.unpickle_cache(settings['M_MATH_CACHE_FILE'])
    else:
        latex2svgextra.unpickle_cache(None)

    hooks_pre_page += [new_page]
    hooks_post_run += [save_cache]

    rst.directives.register_directive('math', Math)
    rst.roles.register_canonical_role('math', math)