# This file is part of python-markups module
# License: 3-clause BSD, see LICENSE file
# Copyright: (C) Dmitry Shachnev, 2012-2018

import os.path

# Some common constants and functions
(LANGUAGE_HOME_PAGE, MODULE_HOME_PAGE, SYNTAX_DOCUMENTATION) = range(3)
CONFIGURATION_DIR = (os.getenv('XDG_CONFIG_HOME') or os.getenv('APPDATA') or
	os.path.expanduser('~/.config'))
MATHJAX_LOCAL_URL = 'file:///usr/share/javascript/mathjax/MathJax.js'
MATHJAX_WEB_URL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js'

PYGMENTS_STYLE = 'default'

def get_pygments_stylesheet(selector, style=None):
	if style is None:
		style = PYGMENTS_STYLE
	if style == '':
		return ''
	try:
		from pygments.formatters import HtmlFormatter
	except ImportError:
		return ''
	else:
		return HtmlFormatter(style=style).get_style_defs(selector) + '\n'

def get_mathjax_url(webenv):
	if os.path.exists(MATHJAX_LOCAL_URL[7:]) and not webenv:
		return MATHJAX_LOCAL_URL
	else:
		return MATHJAX_WEB_URL

@@ -379,19 +379,23 @@
 OCAL_URL
+S
  = 
+(%0A%09
 'file://
@@ -435,16 +435,106 @@
 hJax.js'
+,  # Debian libjs-mathjax%0A%09'file:///usr/share/mathjax/MathJax.js',  # Arch Linux mathjax%0A)
 %0AMATHJAX
@@ -963,50 +963,8 @@
 %09if 
-os.path.exists(MATHJAX_LOCAL_URL%5B7:%5D) and 
 not 
@@ -969,29 +969,33 @@
 t webenv:%0A%09%09
-retur
+for url i
 n MATHJAX_LO
@@ -1001,25 +1001,82 @@
 OCAL_URL
-%0A%09else:%0A%09
+S:%0A%09%09%09if os.path.exists(url%5B7:%5D):  # strip file://%0A%09%09%09%09return url%0A
 %09return 

Add support for Arch Linux mathjax package