File: makeexample.py

package info (click to toggle)
jsxgraph 1.10.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,804 kB
  • sloc: javascript: 82,299; xml: 5,869; java: 1,072; php: 281; makefile: 184; python: 174; cpp: 76; sh: 12
file content (56 lines) | stat: -rw-r--r-- 1,967 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''
    Copyright 2009-2020
        Matthias Ehmann,
        Michael Gerhaeuser,
        Carsten Miller,
        Alfred Wassermann

    This file is part of JSXGraph.

    JSXGraph is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    JSXGraph is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with JSXGraph.  If not, see <https://www.gnu.org/licenses/>.
'''
import sys
import uuid

if __name__ == '__main__':
    code = sys.stdin.readlines()
    
    space = "     * "
    tab = "    "
    
    print("%s%s" % (space, "@example"))
    ''' Print original code '''
    for line in code:
        print("%s%s" % (space, line.rstrip()))
    print(space)
    
    uid = "JXG" + "%s" % (uuid.uuid4())

    ''' Print live code '''
    print("%s%s%s%s" % (space, "</pre><div id=\"", uid, "\" class=\"jxgbox\" style=\"width: 300px; height: 300px;\"></div>"))
    print("%s%s"     % (space, "<script type=\"text/javascript\">"))
    print("%s%s%s"   % (space, tab, "(function() {"))
    print("%s%s%s%s%s"   % (space, tab+tab, "var board = JXG.JSXGraph.initBoard('", uid, "',"))
    print("%s%s%s"   % (space, tab+tab+tab, "{boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});"))
    
    for line in code:
        print("%s%s%s" % (space, tab, line.rstrip()))
    print(space)

    print("%s%s%s"   % (space, tab, "})();"))
    print("%s"       % (space))
    print("%s%s"     % (space, "</script><pre>"))
    print(space)