Coverage for src/markdown_katex/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1# This file is part of the markdown-katex project 

2# https://github.com/mbarkhau/markdown-katex 

3# 

4# Copyright (c) 2019-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License 

5# SPDX-License-Identifier: MIT 

6"""markdown_katex extension. 

7 

8This is an extension for Python-Markdown which 

9uses KaTeX to generate html from tex. 

10""" 

11 

12 

13__version__ = "v202112.1034" 

14 

15from markdown_katex.wrapper import tex2html 

16from markdown_katex.wrapper import get_bin_cmd 

17from markdown_katex.extension import KatexExtension 

18 

19 

20def _make_extension(**kwargs) -> KatexExtension: 

21 return KatexExtension(**kwargs) 

22 

23 

24# Name that conforms with the Markdown extension API 

25# https://python-markdown.github.io/extensions/api/#dot_notation 

26makeExtension = _make_extension 

27 

28 

29TEST_FORMULAS = r""" 

30f(x) = \int_{-\infty}^\infty 

31\hat f(\xi)\,e^{2 \pi i \xi x} 

32\,d\xi 

33 

34--- 

35 

36\displaystyle 

37 

38\frac{1}{ 

39 \Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi} 

40} = 

41 1+\frac{e^{-2\pi}} { 

42 1+\frac{e^{-4\pi}} { 

43 1+\frac{e^{-6\pi}} { 

44 1+\frac{e^{-8\pi}}{ 

45 1+\cdots 

46 } 

47 } 

48 } 

49} 

50 

51--- 

52 

53\displaystyle 

54 

55\left 

56 ( \sum_{k=1}^n a_k b_k 

57\right)^2 

58 

59\leq 

60 

61\left( 

62 \sum_{k=1}^n a_k^2 

63\right) 

64\left( 

65 \sum_{k=1}^n b_k^2 

66\right) 

67 

68--- 

69 

70\overbrace{x + \cdots + x}^{n\rm\ times} 

71- 

72\underbrace{x + \cdots + x}_{n\rm\ times} 

73 

74--- 

75 

76\oiiint \oiint \oint \frac ab + {\scriptscriptstyle \frac cd + \frac ef} + \frac gh 

77 

78--- 

79 

80\Overrightarrow{ABCDE} 

81- 

82\overrightharpoon{abcdec} 

83- 

84\overgroup{ABCDEF} 

85- 

86\undergroup{abcde} 

87- 

88\undergroup{efgp} 

89- 

90\utilde{AB} 

91- 

92\utilde{\utilde{\utilde{AB}}} 

93- 

94\widecheck{AB\widecheck{CD}EF} 

95- 

96\widehat{AB\widehat{CD}EF} 

97 

98""".split( 

99 "---" 

100) 

101 

102 

103__all__ = ['makeExtension', '__version__', 'get_bin_cmd', 'tex2html', 'TEST_FORMULAS']