From 1fc1743765da19a5dcceb42e01b5aa5551886c93 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 29 Oct 2013 15:55:55 -0700 Subject: [PATCH 01/52] Supports MathJax --- jemdoc | 91 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 50 deletions(-) diff --git a/jemdoc b/jemdoc index 0e3e25e..170a84b 100755 --- a/jemdoc +++ b/jemdoc @@ -365,6 +365,26 @@ def insertmenuitems(f, mname, current, prefix): def out(f, s): f.write(s) +def myeqsub(eqtext): + eqtext = eqtext.replace('\\', 'BACKSLASH') + eqtext = eqtext.replace('+', 'PLUS') + eqtext = eqtext.replace('&', 'AMPERSAND') + eqtext = eqtext.replace('<', 'LESSTHAN') + eqtext = eqtext.replace('>', 'GREATERTHAN') + eqtext = eqtext.replace('\n', ' ') + + return eqtext + +def myeqresub(r): + r = re.sub('BACKSLASH', r'\\', r) + r = re.sub('PLUS', '+', r) + r = re.sub('AMPERSAND', '&', r) + r = re.sub('LESSTHAN', '<', r) + r = re.sub('GREATERTHAN', '>', r) + r = re.sub('QUOTATION', '"', r) + + return r + def hb(f, tag, content1, content2=None): """Writes out a halfblock (hb).""" @@ -372,10 +392,14 @@ def hb(f, tag, content1, content2=None): content1 = "" if content2 is None: - out(f, re.sub(r'\|', content1, tag)) +# out(f, re.sub(r'\|', content1, tag)) + r = re.sub(r'\|', content1, tag) + r = myeqresub(r) + out(f, r) else: r = re.sub(r'\|1', content1, tag) r = re.sub(r'\|2', content2, r) + r = myeqresub(r) out(f, r) def pc(f, ditchcomments=True): @@ -519,50 +543,26 @@ def replaceequations(b, f): else: fn = str(abs(hash(eq))) - # Find out the baseline when we first encounter an equation (don't - # bother, otherwise). - # Other initialization stuff which we do only once we know we have - # equations. - if f.baseline is None: - # See if the eqdir exists, and if not, create it. - if not os.path.isdir(f.eqdir): - os.mkdir(f.eqdir) - - # Check that the tools we need exist. - (supported, message) = testeqsupport() - if not supported: - print 'WARNING: equation support disabled.' - print message - f.eqsupport = False - return b - - # Calculate the baseline. - eqt = "0123456789xxxXXxX" - (f.baseline, blfn) = geneq(f, eqt, dpi=f.eqdpi, wl=False, - outname='baseline-' + str(f.eqdpi)) - if os.path.exists(blfn): - os.remove(blfn) - - fn = fn + '-' + str(f.eqdpi) - (depth, fullfn) = geneq(f, eq, dpi=f.eqdpi, wl=wl, outname=fn) - fullfn = fullfn.replace('\\', '/') - - offset = depth - f.baseline + 1 - eqtext = allreplace(eq) - eqtext = eqtext.replace('\\', '') - eqtext = eqtext.replace('\n', ' ') +# print eqtext +# eqtext = eqtext.replace('\\', '') + eqtext = myeqsub(eqtext) # Double braces will cause problems with escaping of image tag. eqtext = eqtext.replace('{{', 'DOUBLEOPENBRACE') eqtext = eqtext.replace('}}', 'DOUBLECLOSEBRACE') if wl: - b = b[:m.start()] + \ - '{{\n
%s\n
}}' % (fullfn, eqtext) + b[m.end():] +# b = b[:m.start()] + \ +# '{{\n
%s\n
}}' % (fullfn, eqtext) + b[m.end():] + b = b[:m.start()] + 'BACKSLASH(\n' + eqtext + '\nBACKSLASH)'+ b[m.end():] + #b = b[:m.start()] + 'BACKSLASH(BACKSLASHbegin{equation}\n' + eqtext + '\nBACKSLASHend{equation}BACKSLASH)'+ b[m.end():] + b = '

' + b + '

' + b = myeqsub(b) else: - b = b[:m.start()] + \ - '{{%s}}' % (fullfn, eqtext, offset) + b[m.end():] +# b = b[:m.start()] + \ +# '{{%s}}' % (fullfn, eqtext, offset) + b[m.end():] + b = b[:m.start()] + '{{BACKSLASH(' + eqtext + 'BACKSLASH)}}' + b[m.end():] # jem: also clean out line breaks in the alttext? m = r.search(b, m.start()) @@ -715,6 +715,7 @@ def br(b, f, tableblock=False): # Deal with non-breaking space ~. r = re.compile(r"(? Date: Tue, 29 Oct 2013 15:59:45 -0700 Subject: [PATCH 02/52] Supports _underline_ --- jemdoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 170a84b..f0f33aa 100755 --- a/jemdoc +++ b/jemdoc @@ -681,7 +681,11 @@ def br(b, f, tableblock=False): # Deal with *bold*. r = re.compile(r'(?\1', b) - + + # Deal with _underline_. + r = re.compile(r'(?\1', b) + # Deal with +monospace+. r = re.compile(r'(?\1', b) From 1b7400bb1c8d5db0e8904268a21d1f90c22c240e Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 29 Oct 2013 16:01:28 -0700 Subject: [PATCH 03/52] Opens links in new tabs --- jemdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index f0f33aa..691f5a2 100755 --- a/jemdoc +++ b/jemdoc @@ -633,7 +633,7 @@ def replacelinks(b): # remove any mailto before labelling. linkname = re.sub('^mailto:', '', link) - b = b[:m.start()] + r'%s<\/a>' % (link, linkname) + b[m.end():] + b = b[:m.start()] + r'%s<\/a>' % (link, linkname) + b[m.end():] m = r.search(b, m.start()) From 58e1c97c90d123b6048a5892cb9e50cad6c94cb2 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Wed, 20 Nov 2013 22:41:22 -0800 Subject: [PATCH 04/52] dashlist() supports MathJax --- jemdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 691f5a2..638ef55 100755 --- a/jemdoc +++ b/jemdoc @@ -1048,7 +1048,7 @@ def dashlist(f, ordered=False): # same level, make a new list item. out(f.outf, '\n\n
  • ') - out(f.outf, '

    ' + br(s, f) + '

    ') + out(f.outf, '

    ' + myeqresub(br(s, f)) + '

    ') level = newlevel for i in range(level): From 651c16d6439683f74587b21f81301bd1e57c2455 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 14 Mar 2014 00:18:03 -0700 Subject: [PATCH 05/52] Underscore in equations are correctly handled --- jemdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jemdoc b/jemdoc index 638ef55..628dd11 100755 --- a/jemdoc +++ b/jemdoc @@ -372,6 +372,7 @@ def myeqsub(eqtext): eqtext = eqtext.replace('<', 'LESSTHAN') eqtext = eqtext.replace('>', 'GREATERTHAN') eqtext = eqtext.replace('\n', ' ') + eqtext = eqtext.replace('_', 'UNDERSCORE') return eqtext @@ -382,6 +383,7 @@ def myeqresub(r): r = re.sub('LESSTHAN', '<', r) r = re.sub('GREATERTHAN', '>', r) r = re.sub('QUOTATION', '"', r) + r = re.sub('UNDERSCORE', '_', r) return r From 8981c399ae212591a1737c435d15341af4b57107 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 14 Mar 2014 01:26:44 -0700 Subject: [PATCH 06/52] Link can open new window if the link starts with \ --- jemdoc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/jemdoc b/jemdoc index 628dd11..b7a24ad 100755 --- a/jemdoc +++ b/jemdoc @@ -190,7 +190,7 @@ def standardconf(): [menuitem] -
    + [specificcss] @@ -199,7 +199,7 @@ def standardconf(): [currentmenuitem] - + [nomenu]
    @@ -329,6 +329,12 @@ def insertmenuitems(f, mname, current, prefix): if r: # then we have a menu item. link = r.group(2) + if link[0] == '\\': + option = ' target="blank"' + link = link[1:] + else: + option = '' + # Don't use prefix if we have an absolute link. if '://' not in r.group(2): link = prefix + allreplace(link) @@ -353,9 +359,9 @@ def insertmenuitems(f, mname, current, prefix): menuitem += br(re.sub(r'(?%s<\/a>' % (link, linkname) + b[m.end():] + b = b[:m.start()] + r'%s<\/a>' % (link, option, linkname) + b[m.end():] m = r.search(b, m.start()) From b6bdfcd820ad03c2a89efe4d0e700d8470c51cc9 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 14 Mar 2014 01:43:18 -0700 Subject: [PATCH 07/52] If menu items start with \, open a new tab; if normal links start with /, open in the current tab --- jemdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jemdoc b/jemdoc index b7a24ad..5df016c 100755 --- a/jemdoc +++ b/jemdoc @@ -626,11 +626,11 @@ def replacelinks(b): while m: m1 = m.group(1).strip() - if m1[0] == '\\': - option = ' target="blank"' + if m1[0] == '/': + option = '' m1 = m1[1:] else: - option = '' + option = ' target="blank"' if '@' in m1 and not m1.startswith('mailto:') and not \ m1.startswith('http://'): From 3b60592ecc51cd092b2910f71a773d7a06ca75d2 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 28 Mar 2014 17:34:57 -0700 Subject: [PATCH 08/52] Examples of the usage of additional features are added --- example/MENU | 5 + example/jemdoc.css | 369 ++++++++++++++++++++++++++++++++++++++ example/link.jemdoc | 8 + example/mathjax.jemdoc | 22 +++ example/mysite.conf | 4 + example/underscore.jemdoc | 7 + 6 files changed, 415 insertions(+) create mode 100644 example/MENU create mode 100644 example/jemdoc.css create mode 100644 example/link.jemdoc create mode 100644 example/mathjax.jemdoc create mode 100644 example/mysite.conf create mode 100644 example/underscore.jemdoc diff --git a/example/MENU b/example/MENU new file mode 100644 index 0000000..fa78d40 --- /dev/null +++ b/example/MENU @@ -0,0 +1,5 @@ +Additional Features + MathJax [mathjax.html] + Underscore [underscore.html] + Link [link.html] + Open in New Tab [\http://www.google.com] diff --git a/example/jemdoc.css b/example/jemdoc.css new file mode 100644 index 0000000..9fe8685 --- /dev/null +++ b/example/jemdoc.css @@ -0,0 +1,369 @@ +/* Default css file for jemdoc. */ + +table#tlayout { + border: none; + border-collapse: separate; + background: white; +} + +body { + background: white; + font-family: Georgia, serif; + padding-bottom: 8px; + margin: 0; +} + +#layout-menu { + background: #f6f6f6; + border: 1px solid #dddddd; + padding-top: 0.5em; + padding-left: 8px; + padding-right: 8px; + font-size: 1.0em; + width: auto; + white-space: nowrap; + text-align: left; + vertical-align: top; +} + +#layout-menu td { + background: #f4f4f4; + vertical-align: top; +} + +#layout-content { + padding-top: 0.0em; + padding-left: 1.0em; + padding-right: 1.0em; + border: none; + background: white; + text-align: left; + vertical-align: top; + min-width: 800px; + width: 800px; +} + +#layout-menu a { + line-height: 1.5em; + margin-left: 0.5em; +} + +tt { + background: #ffffdd; +} + +pre, tt { + font-size: 90%; + font-family: monaco, monospace; +} + +a, a > tt { + color: #224b8d; + text-decoration: none; +} + +a:hover { + border-bottom: 1px gray dotted; +} + +#layout-menu a.current:link, #layout-menu a.current:visited { + color: #022b6d; + border-bottom: 1px gray solid; +} +#layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover { + color: #527bbd; + text-decoration: none; +} +#layout-menu a:hover { + text-decoration: none; +} + +div.menu-category { + border-bottom: 1px solid gray; + margin-top: 0.8em; + padding-top: 0.2em; + padding-bottom: 0.1em; + font-weight: bold; +} + +div.menu-item { + padding-left: 16px; + text-indent: -16px; +} + +div#toptitle { + padding-bottom: 0.2em; + margin-bottom: 1.5em; + border-bottom: 3px double gray; +} + +/* Reduce space if we begin the page with a title. */ +div#toptitle + h2, div#toptitle + h3 { + margin-top: -0.7em; +} + +div#subtitle { + margin-top: 0.0em; + margin-bottom: 0.0em; + padding-top: 0em; + padding-bottom: 0.1em; +} + +em { + font-style: italic; +} + +strong { + font-weight: bold; +} + + +h1, h2, h3 { + color: #527bbd; + margin-top: 0.7em; + margin-bottom: 0.3em; + padding-bottom: 0.2em; + line-height: 1.0; + padding-top: 0.5em; + border-bottom: 1px solid #aaaaaa; +} + +h1 { + font-size: 165%; +} + +h2 { + padding-top: 0.8em; + font-size: 125%; +} + +h2 + h3 { + padding-top: 0.2em; +} + +h3 { + font-size: 110%; + border-bottom: none; +} + +p { + margin-top: 0.0em; + margin-bottom: 0.8em; + padding: 0; + line-height: 1.3; +} + +pre { + padding: 0; + margin: 0; +} + +div#footer { + font-size: small; + border-top: 1px solid #c0c0c0; + padding-top: 0.1em; + margin-top: 4.0em; + color: #c0c0c0; +} + +div#footer a { + color: #80a0b0; +} + +div#footer-text { + float: left; + padding-bottom: 8px; +} + +ul, ol, dl { + margin-top: 0.2em; + padding-top: 0; + margin-bottom: 0.8em; +} + +dt { + margin-top: 0.5em; + margin-bottom: 0; +} + +dl { + margin-left: 20px; +} + +dd { + color: #222222; +} + +dd > *:first-child { + margin-top: 0; +} + +ul { + list-style-position: outside; + list-style-type: square; +} + +p + ul, p + ol { + margin-top: -0.5em; +} + +li ul, li ol { + margin-top: -0.3em; +} + +ol { + list-style-position: outside; + list-style-type: decimal; +} + +li p, dd p { + margin-bottom: 0.3em; +} + + +ol ol { + list-style-type: lower-alpha; +} + +ol ol ol { + list-style-type: lower-roman; +} + +p + div.codeblock { + margin-top: -0.6em; +} + +div.codeblock, div.infoblock { + margin-right: 0%; + margin-top: 1.2em; + margin-bottom: 1.3em; +} + +div.blocktitle { + font-weight: bold; + color: #cd7b62; + margin-top: 1.2em; + margin-bottom: 0.1em; +} + +div.blockcontent { + border: 1px solid silver; + padding: 0.3em 0.5em; +} + +div.infoblock > div.blockcontent { + background: #ffffee; +} + +div.blockcontent p + ul, div.blockcontent p + ol { + margin-top: 0.4em; +} + +div.infoblock p { + margin-bottom: 0em; +} + +div.infoblock li p, div.infoblock dd p { + margin-bottom: 0.5em; +} + +div.infoblock p + p { + margin-top: 0.8em; +} + +div.codeblock > div.blockcontent { + background: #f6f6f6; +} + +span.pycommand { + color: #000070; +} + +span.statement { + color: #008800; +} +span.builtin { + color: #000088; +} +span.special { + color: #990000; +} +span.operator { + color: #880000; +} +span.error { + color: #aa0000; +} +span.comment, span.comment > *, span.string, span.string > * { + color: #606060; +} + +@media print { + #layout-menu { display: none; } +} + +#fwtitle { + margin: 2px; +} + +#fwtitle #toptitle { + padding-left: 0.5em; + margin-bottom: 0.5em; +} + +#layout-content h1:first-child, #layout-content h2:first-child, #layout-content h3:first-child { + margin-top: -0.7em; +} + +div#toptitle h1, #layout-content div#toptitle h1 { + margin-bottom: 0.0em; + padding-bottom: 0.1em; + padding-top: 0; + margin-top: 0.5em; + border-bottom: none; +} + +img.eq { + padding: 0; + padding-left: 0.1em; + padding-right: 0.1em; + margin: 0; +} + +img.eqwl { + padding-left: 2em; + padding-top: 0.6em; + padding-bottom: 0.2em; + margin: 0; +} + +table { + border: 2px solid black; + border-collapse: collapse; +} + +td { + padding: 2px; + padding-left: 0.5em; + padding-right: 0.5em; + text-align: center; + border: 1px solid gray; +} + +table + table { + margin-top: 1em; +} + +tr.heading { + font-weight: bold; + border-bottom: 2px solid black; +} + +img { + border: none; +} + +table.imgtable, table.imgtable td { + border: none; + text-align: left; +} diff --git a/example/link.jemdoc b/example/link.jemdoc new file mode 100644 index 0000000..059a47c --- /dev/null +++ b/example/link.jemdoc @@ -0,0 +1,8 @@ +# jemdoc: menu{MENU}{link.html}, nofooter +== Underscore Example + +You can control the behavior of a link by putting a slash (+\/+) character at the beginning of the link address or not: by putting a slash, you can make the link open in the current web broswer tab. + +For example, [mathjax.html \[mathjax.html\]] opens in a new web broswer tab, but [/mathjax.html \[\/mathjax.html\]] opens in the same web browser tab. The link opening in a new tab is useful for linking an external website (like [http://www.google.com]), wherease the link opening in the same tab is useful for liking your jemdoc page (such as the page linked as a +jemdoc+ menu item on the left panel). + +A +jemdoc+ menu item on the left panel opens in the same tab by default, but you can make it open in a new tab by putting a backslash (+\\+) character in the beginning of the link of the menu item. This is useful to link an external website as a menu item. See this usage in "Open in New Tab" menu item on the left panel, which is defined in MENU file. diff --git a/example/mathjax.jemdoc b/example/mathjax.jemdoc new file mode 100644 index 0000000..f012209 --- /dev/null +++ b/example/mathjax.jemdoc @@ -0,0 +1,22 @@ +# jemdoc: menu{MENU}{mathjax.html}, nofooter +== MathJax Example + +In this modified version of +jemdoc+, a LaTeX equation block can be typed in as +\( +\nabla \cdot \mathbf{D} = \rho_f\\ +\nabla \cdot \mathbf{B} = 0,\\ +\nabla \times \mathbf{E} = -\frac{\partial\mathbf{B}}{\partial t}\\ +\nabla \times \mathbf{H} = \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}. +\) + +You can also align equations using LaTeX's +align+ block: +\( +\begin{align} +\nabla \cdot \mathbf{D} &= \rho_f\\ +\nabla \cdot \mathbf{B} &= 0,\\ +\nabla \times \mathbf{E} &= -\frac{\partial\mathbf{B}}{\partial t}\\ +\nabla \times \mathbf{H} &= \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}. +\end{align} +\) + +You can also type inline equations as $A x = b$. diff --git a/example/mysite.conf b/example/mysite.conf new file mode 100644 index 0000000..25d724d --- /dev/null +++ b/example/mysite.conf @@ -0,0 +1,4 @@ +[bodyend] + + diff --git a/example/underscore.jemdoc b/example/underscore.jemdoc new file mode 100644 index 0000000..8681550 --- /dev/null +++ b/example/underscore.jemdoc @@ -0,0 +1,7 @@ +# jemdoc: menu{MENU}{underscore.html}, nofooter +== Underscore Example + +Like *bold* and /italic/, _underscore_ can be used for emphasis in this modified version of +jemdoc+. Useful for highlighting different parts of a bibliography item as: + +1. _First Author_, Second Author, and *Corresponding Author*, "Amazing Paper," /High-impact Journal/, vol.~1, pp.~1--10 (2014). + From 4083850c18aca12c7242cbe8478b0ab0423f77f5 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 28 Mar 2014 17:51:06 -0700 Subject: [PATCH 09/52] example/README is added --- example/README | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 example/README diff --git a/example/README b/example/README new file mode 100644 index 0000000..6ada5a8 --- /dev/null +++ b/example/README @@ -0,0 +1,7 @@ +This example/ directory contains jemdoc source files that create an example website that demonstrates the additional features that I implemented in the original jemdoc. To build the website, execute the following command in this example/ directory: + +../jemdoc -c mysite.conf *.jemdoc + +I implemented those features only for my convenience, and just focused on "making them work" rather than spending too much time to figure out how to implement them in an elegant way. Therefore, the modification is messy and probably contains many errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and adopt them in the official jemdoc release. + +- Wonseok Shin From 86d9e05557274133256579b36ef80d27a5207c23 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 28 Mar 2014 18:49:01 -0700 Subject: [PATCH 10/52] example/link.jemdoc is updated --- example/link.jemdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/link.jemdoc b/example/link.jemdoc index 059a47c..73817f3 100644 --- a/example/link.jemdoc +++ b/example/link.jemdoc @@ -1,8 +1,8 @@ # jemdoc: menu{MENU}{link.html}, nofooter == Underscore Example -You can control the behavior of a link by putting a slash (+\/+) character at the beginning of the link address or not: by putting a slash, you can make the link open in the current web broswer tab. +You can control the behavior of a link: by default the link opens in a new web broswer tab, but by putting a slash (+\/+) character at the beginning of the link address you can make it open in the current web broswer tab. -For example, [mathjax.html \[mathjax.html\]] opens in a new web broswer tab, but [/mathjax.html \[\/mathjax.html\]] opens in the same web browser tab. The link opening in a new tab is useful for linking an external website (like [http://www.google.com]), wherease the link opening in the same tab is useful for liking your jemdoc page (such as the page linked as a +jemdoc+ menu item on the left panel). +For example, [mathjax.html \[mathjax.html\]] opens in a new web broswer tab, but [/mathjax.html \[\/mathjax.html\]] opens in the current web browser tab. The link opening in a new tab is useful for linking an external website (like [http://www.google.com]), whereas the link opening in the current tab is useful for liking your jemdoc page (such as the page linked as a jemdoc menu item on the left panel). -A +jemdoc+ menu item on the left panel opens in the same tab by default, but you can make it open in a new tab by putting a backslash (+\\+) character in the beginning of the link of the menu item. This is useful to link an external website as a menu item. See this usage in "Open in New Tab" menu item on the left panel, which is defined in MENU file. +Unlike the link in the main text, a jemdoc menu item link on the left panel opens in the current tab by default, because you want to stay in the same tab while navigating menu items. However, you can override this default behavior and make it open in a new tab by putting a backslash (+\\+) character in the beginning of the link of the menu item. This is useful when putting an external website as a menu item. See this usage in "Open in New Tab" menu item on the left panel, which is defined in MENU file. From a879e36fad3f374c4641d4f4a3bc2783de47c365 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 28 Mar 2014 19:28:15 -0700 Subject: [PATCH 11/52] example/README is updated --- example/README | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/example/README b/example/README index 6ada5a8..0bf8083 100644 --- a/example/README +++ b/example/README @@ -1,7 +1,9 @@ -This example/ directory contains jemdoc source files that create an example website that demonstrates the additional features that I implemented in the original jemdoc. To build the website, execute the following command in this example/ directory: +This example/ directory contains jemdoc source files that create an example website that demonstrates the new features that I added to the original jemdoc. To build the website, execute the following command in this example/ directory: ../jemdoc -c mysite.conf *.jemdoc -I implemented those features only for my convenience, and just focused on "making them work" rather than spending too much time to figure out how to implement them in an elegant way. Therefore, the modification is messy and probably contains many errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and adopt them in the official jemdoc release. +Note that you need mysite.conf to use MathJax in jemdoc. + +I implemented the new features only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) - Wonseok Shin From 1fcb5bc8d1fe57a26c71318e91e483f6558bbcf9 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Thu, 3 Apr 2014 19:19:33 -0700 Subject: [PATCH 12/52] \(...\) in jemdoc is converted to \[...\] in HTML to correctly express displayed equations --- jemdoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jemdoc b/jemdoc index 5df016c..6b0d6d4 100755 --- a/jemdoc +++ b/jemdoc @@ -373,6 +373,8 @@ def out(f, s): def myeqsub(eqtext): eqtext = eqtext.replace('\\', 'BACKSLASH') + eqtext = eqtext.replace('[', 'OPENBRACKET') + eqtext = eqtext.replace(']', 'CLOSEBRACKET') eqtext = eqtext.replace('+', 'PLUS') eqtext = eqtext.replace('&', 'AMPERSAND') eqtext = eqtext.replace('<', 'LESSTHAN') @@ -384,6 +386,8 @@ def myeqsub(eqtext): def myeqresub(r): r = re.sub('BACKSLASH', r'\\', r) + r = re.sub('OPENBRACKET', '[', r) + r = re.sub('CLOSEBRACKET', ']', r) r = re.sub('PLUS', '+', r) r = re.sub('AMPERSAND', '&', r) r = re.sub('LESSTHAN', '<', r) @@ -568,14 +572,14 @@ def replaceequations(b, f): if wl: # b = b[:m.start()] + \ # '{{\n
    %s\n
    }}' % (fullfn, eqtext) + b[m.end():] - b = b[:m.start()] + 'BACKSLASH(\n' + eqtext + '\nBACKSLASH)'+ b[m.end():] + b = b[:m.start()] + 'BACKSLASHOPENBRACKET\n' + eqtext + '\nBACKSLASHCLOSEBRACKET'+ b[m.end():] #b = b[:m.start()] + 'BACKSLASH(BACKSLASHbegin{equation}\n' + eqtext + '\nBACKSLASHend{equation}BACKSLASH)'+ b[m.end():] b = '

    ' + b + '

    ' b = myeqsub(b) else: # b = b[:m.start()] + \ # '{{%s}}' % (fullfn, eqtext, offset) + b[m.end():] - b = b[:m.start()] + '{{BACKSLASH(' + eqtext + 'BACKSLASH)}}' + b[m.end():] + b = b[:m.start()] + 'BACKSLASH(' + eqtext + 'BACKSLASH)' + b[m.end():] # jem: also clean out line breaks in the alttext? m = r.search(b, m.start()) From abe1ed69760bad9284580f6ec5510b24efe28747 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Thu, 3 Apr 2014 22:20:19 -0700 Subject: [PATCH 13/52] footer points the GitHub jemdoc+MathJax page --- jemdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 6b0d6d4..e353135 100755 --- a/jemdoc +++ b/jemdoc @@ -252,7 +252,7 @@ def standardconf():
    [lastupdated] - Page generated |, by jemdoc. + Page generated |, by jemdoc+MathJax. [sourcelink] (source) From 28e30da94da2938de68b0e71a8b645b984c3956a Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 4 Apr 2014 00:33:00 -0700 Subject: [PATCH 14/52] myeqsub() and myeqresub() is done more safely --- jemdoc | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/jemdoc b/jemdoc index e353135..9188763 100755 --- a/jemdoc +++ b/jemdoc @@ -252,7 +252,7 @@ def standardconf(): [lastupdated] - Page generated |, by jemdoc+MathJax. + Page generated |, by jemdoc+MathJax. [sourcelink] (source) @@ -372,28 +372,28 @@ def out(f, s): f.write(s) def myeqsub(eqtext): - eqtext = eqtext.replace('\\', 'BACKSLASH') - eqtext = eqtext.replace('[', 'OPENBRACKET') - eqtext = eqtext.replace(']', 'CLOSEBRACKET') - eqtext = eqtext.replace('+', 'PLUS') - eqtext = eqtext.replace('&', 'AMPERSAND') - eqtext = eqtext.replace('<', 'LESSTHAN') - eqtext = eqtext.replace('>', 'GREATERTHAN') + eqtext = eqtext.replace('\\', 'BACKSLASH65358') + eqtext = eqtext.replace('[', 'OPENBRACKET65358') + eqtext = eqtext.replace(']', 'CLOSEBRACKET65358') + eqtext = eqtext.replace('+', 'PLUS65358') + eqtext = eqtext.replace('&', 'AMPERSAND65358') + eqtext = eqtext.replace('<', 'LESSTHAN65358') + eqtext = eqtext.replace('>', 'GREATERTHAN65358') eqtext = eqtext.replace('\n', ' ') - eqtext = eqtext.replace('_', 'UNDERSCORE') + eqtext = eqtext.replace('_', 'UNDERSCORE65358') return eqtext def myeqresub(r): - r = re.sub('BACKSLASH', r'\\', r) - r = re.sub('OPENBRACKET', '[', r) - r = re.sub('CLOSEBRACKET', ']', r) - r = re.sub('PLUS', '+', r) - r = re.sub('AMPERSAND', '&', r) - r = re.sub('LESSTHAN', '<', r) - r = re.sub('GREATERTHAN', '>', r) - r = re.sub('QUOTATION', '"', r) - r = re.sub('UNDERSCORE', '_', r) + r = re.sub('BACKSLASH65358', r'\\', r) + r = re.sub('OPENBRACKET65358', '[', r) + r = re.sub('CLOSEBRACKET65358', ']', r) + r = re.sub('PLUS65358', '+', r) + r = re.sub('AMPERSAND65358', '&', r) + r = re.sub('LESSTHAN65358', '<', r) + r = re.sub('GREATERTHAN65358', '>', r) + r = re.sub('QUOTATION65358', '"', r) + r = re.sub('UNDERSCORE65358', '_', r) return r @@ -572,14 +572,14 @@ def replaceequations(b, f): if wl: # b = b[:m.start()] + \ # '{{\n
    %s\n
    }}' % (fullfn, eqtext) + b[m.end():] - b = b[:m.start()] + 'BACKSLASHOPENBRACKET\n' + eqtext + '\nBACKSLASHCLOSEBRACKET'+ b[m.end():] + b = b[:m.start()] + 'BACKSLASH65358OPENBRACKET65358\n' + eqtext + '\nBACKSLASH65358CLOSEBRACKET65358'+ b[m.end():] #b = b[:m.start()] + 'BACKSLASH(BACKSLASHbegin{equation}\n' + eqtext + '\nBACKSLASHend{equation}BACKSLASH)'+ b[m.end():] - b = '

    ' + b + '

    ' + b = '

    ' + b + '

    ' b = myeqsub(b) else: # b = b[:m.start()] + \ # '{{%s}}' % (fullfn, eqtext, offset) + b[m.end():] - b = b[:m.start()] + 'BACKSLASH(' + eqtext + 'BACKSLASH)' + b[m.end():] + b = b[:m.start()] + 'BACKSLASH65358(' + eqtext + 'BACKSLASH65358)' + b[m.end():] # jem: also clean out line breaks in the alttext? m = r.search(b, m.start()) From b042f7b66ec125abc8a74946565b01b6aa6e9737 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 4 Apr 2014 09:39:22 -0700 Subject: [PATCH 15/52] mysite.conf is changed to do equation numbering by default --- example/mysite.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/example/mysite.conf b/example/mysite.conf index 25d724d..34d341e 100644 --- a/example/mysite.conf +++ b/example/mysite.conf @@ -1,4 +1,8 @@ [bodyend] - + From c7603843e1b7328d1b93cef8cf9ebc3e171f30e6 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 4 Apr 2014 10:40:44 -0700 Subject: [PATCH 16/52] Underscores in links are not replaced with ... --- jemdoc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 9188763..8df5b2c 100755 --- a/jemdoc +++ b/jemdoc @@ -371,6 +371,16 @@ def insertmenuitems(f, mname, current, prefix): def out(f, s): f.write(s) +def myussub(link): + link = link.replace('_', 'UNDERSCORE65358') + + return link + +def myusresub(r): + r = re.sub('UNDERSCORE65358', '_', r) + + return r + def myeqsub(eqtext): eqtext = eqtext.replace('\\', 'BACKSLASH65358') eqtext = eqtext.replace('[', 'OPENBRACKET65358') @@ -649,6 +659,7 @@ def replacelinks(b): link = re.sub(r'(\+\{\{|\}\}\+)', r'%', link) link = quote(link) + link = myussub(link) # to prevent _ in address from changing if m.group(2): linkname = m.group(2).strip() @@ -705,9 +716,10 @@ def br(b, f, tableblock=False): r = re.compile(r'(?\1', b) - # Deal with _underline_. + # Deal with _underscore_. r = re.compile(r'(?\1', b) + b = myusresub(b) # Deal with +monospace+. r = re.compile(r'(? Date: Sat, 5 Apr 2014 00:31:54 -0700 Subject: [PATCH 17/52] example/ is updated --- example/README | 4 +++- example/mathjax.jemdoc | 32 ++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/example/README b/example/README index 0bf8083..77a7e50 100644 --- a/example/README +++ b/example/README @@ -2,7 +2,9 @@ This example/ directory contains jemdoc source files that create an example webs ../jemdoc -c mysite.conf *.jemdoc -Note that you need mysite.conf to use MathJax in jemdoc. +This generates a few HTML files, which you can open in any web browser to see the results. + +MathJax configuration is done in mysite.conf. Change mysite.conf to control the behavior of MathJax. I implemented the new features only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) diff --git a/example/mathjax.jemdoc b/example/mathjax.jemdoc index f012209..13b46cb 100644 --- a/example/mathjax.jemdoc +++ b/example/mathjax.jemdoc @@ -9,14 +9,38 @@ In this modified version of +jemdoc+, a LaTeX equation block can be typed in as \nabla \times \mathbf{H} = \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}. \) -You can also align equations using LaTeX's +align+ block: +You can also align equations using LaTeX's +aligned+ block: \( -\begin{align} +\begin{aligned} +\nabla \cdot \mathbf{D} &= \rho_f\\ +\nabla \cdot \mathbf{B} &= 0\\ +\nabla \times \mathbf{E} &= -\frac{\partial\mathbf{B}}{\partial t}\\ +\nabla \times \mathbf{H} &= \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}. +\end{aligned} +\) + +To number the equation block, wrap the equations with LaTeX's +equation+ block: +\( +\begin{equation} +\begin{aligned} \nabla \cdot \mathbf{D} &= \rho_f\\ -\nabla \cdot \mathbf{B} &= 0,\\ +\nabla \cdot \mathbf{B} &= 0\\ \nabla \times \mathbf{E} &= -\frac{\partial\mathbf{B}}{\partial t}\\ \nabla \times \mathbf{H} &= \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}. +\end{aligned} +\end{equation} +\) + +Instead, you can use LaTeX's +align+ (not +aligned+) block to number the individual equations: +\( +\begin{align} +\nabla \cdot \mathbf{D} &= \rho_f\label{eq:D}\\ +\nabla \cdot \mathbf{B} &= 0\label{eq:B}\\ +\nabla \times \mathbf{E} &= -\frac{\partial\mathbf{B}}{\partial t}\label{eq:E}\\ +\nabla \times \mathbf{H} &= \mathbf{J}_f - \frac{\partial\mathbf{D}}{\partial t}\label{eq:H} \end{align} \) -You can also type inline equations as $A x = b$. +You can also type inline equations as $A x = b$. Referencing equations is done as Eqs.~$\eqref{eq:E}$ and $\eqref{eq:H}$. + + From dba542b5fa8363d1a32cc77b5c9bf97a62fdfb28 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Sat, 5 Apr 2014 17:15:44 -0700 Subject: [PATCH 18/52] Show Math As > TeX Commands shows LaTeX commands correctly newlined --- jemdoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jemdoc b/jemdoc index 8df5b2c..8fd7f64 100755 --- a/jemdoc +++ b/jemdoc @@ -389,7 +389,7 @@ def myeqsub(eqtext): eqtext = eqtext.replace('&', 'AMPERSAND65358') eqtext = eqtext.replace('<', 'LESSTHAN65358') eqtext = eqtext.replace('>', 'GREATERTHAN65358') - eqtext = eqtext.replace('\n', ' ') +# eqtext = eqtext.replace('\n', ' ') eqtext = eqtext.replace('_', 'UNDERSCORE65358') return eqtext @@ -582,9 +582,10 @@ def replaceequations(b, f): if wl: # b = b[:m.start()] + \ # '{{\n
    %s\n
    }}' % (fullfn, eqtext) + b[m.end():] - b = b[:m.start()] + 'BACKSLASH65358OPENBRACKET65358\n' + eqtext + '\nBACKSLASH65358CLOSEBRACKET65358'+ b[m.end():] + #b = b[:m.start()] + 'BACKSLASH65358OPENBRACKET65358\n' + eqtext + '\nBACKSLASH65358CLOSEBRACKET65358'+ b[m.end():] + b = b[:m.start()] + 'BACKSLASH65358OPENBRACKET65358' + eqtext + 'BACKSLASH65358CLOSEBRACKET65358'+ b[m.end():] #b = b[:m.start()] + 'BACKSLASH(BACKSLASHbegin{equation}\n' + eqtext + '\nBACKSLASHend{equation}BACKSLASH)'+ b[m.end():] - b = '

    ' + b + '

    ' + b = '

    \n' + b + '\n

    ' b = myeqsub(b) else: # b = b[:m.start()] + \ From 4c2901dcecb6197ffda266186432b4cc054623e7 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 01:18:32 -0700 Subject: [PATCH 19/52] README is combined --- README | 47 ++++++++++++++++++++++++++++++++++++++++------- example/README | 11 ----------- 2 files changed, 40 insertions(+), 18 deletions(-) delete mode 100644 example/README diff --git a/README b/README index 629bfaf..10d76f7 100644 --- a/README +++ b/README @@ -1,9 +1,42 @@ -jemdoc is a light text-based markup language designed for creating websites. It -takes a text file written with jemdoc markup, an optional configuration file and -an optional menu file, and makes static websites that look something like -http://jemdoc.jaboc.net/. +jemdoc+MathJax +============== +jemdoc is a light text-based markup language designed for creating websites. See http://jemdoc.jaboc.net/ for more information and the detailed usage of jemdoc. -It was written by me, Jacob Mattingley, in 2007, and definitely isn't the type -of code I would put on my CV. Lots of people use jemdoc, especially in academia. +jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://www.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. + +Additional features +------------------- + * MathJax support + * Underscore + * Control of the behavior of links: open in the current web broswer tab or in a new tab + +How to use jemdoc+MathJax +------------------------- +Once you download jemdoc+MathJax, you can install and use it like the original jemdoc. See the [jemdoc user guide](http://jemdoc.jaboc.net/using.html), expecially the [example page](http://jemdoc.jaboc.net/example.html). + +The usage of the additional features implemented in jemdoc+MathJax can be found in example/ directory in this package. The directory contains jemdoc source files that create an example website that demonstrates the additional features. To build the website, execute the following command in this example/ directory: + +../jemdoc -c mysite.conf *.jemdoc + +This generates a few HTML files, which you can open in any web browser to see the results. + +MathJax configuration is done in mysite.conf. Change mysite.conf to control the behavior of MathJax. + +Disclaimer +---------- +I implemented the new features in jemdoc+MathJax only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) + +- Wonseok Shin + +README of the original jemdoc +----------------------------- +> jemdoc is a light text-based markup language designed for creating websites. It +> takes a text file written with jemdoc markup, an optional configuration file and +> an optional menu file, and makes static websites that look something like +> http://jemdoc.jaboc.net/. +> +> It was written by me, Jacob Mattingley, in 2007, and definitely isn't the type +> of code I would put on my CV. Lots of people use jemdoc, especially in academia. +> +> Much more info at http://jemdoc.jaboc.net/. -Much more info at http://jemdoc.jaboc.net/. diff --git a/example/README b/example/README deleted file mode 100644 index 77a7e50..0000000 --- a/example/README +++ /dev/null @@ -1,11 +0,0 @@ -This example/ directory contains jemdoc source files that create an example website that demonstrates the new features that I added to the original jemdoc. To build the website, execute the following command in this example/ directory: - -../jemdoc -c mysite.conf *.jemdoc - -This generates a few HTML files, which you can open in any web browser to see the results. - -MathJax configuration is done in mysite.conf. Change mysite.conf to control the behavior of MathJax. - -I implemented the new features only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) - -- Wonseok Shin From 81c83dd88737a0b56b895aae08cfe3dc9db50990 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 01:21:56 -0700 Subject: [PATCH 20/52] README -> README.md --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 7e3eb2c935ef380719c2258aef48fff5568206b7 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 01:24:30 -0700 Subject: [PATCH 21/52] README.md is updated --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10d76f7..b1c90c5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc Additional features ------------------- * MathJax support - * Underscore + * _Underscore_ * Control of the behavior of links: open in the current web broswer tab or in a new tab How to use jemdoc+MathJax @@ -16,7 +16,9 @@ Once you download jemdoc+MathJax, you can install and use it like the original j The usage of the additional features implemented in jemdoc+MathJax can be found in example/ directory in this package. The directory contains jemdoc source files that create an example website that demonstrates the additional features. To build the website, execute the following command in this example/ directory: +``` ../jemdoc -c mysite.conf *.jemdoc +``` This generates a few HTML files, which you can open in any web browser to see the results. From a59999f760f9ba2cea9e6e75d62e40c476f49afd Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 01:25:56 -0700 Subject: [PATCH 22/52] README.md is updated --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1c90c5..f6db54c 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc Additional features ------------------- - * MathJax support - * _Underscore_ - * Control of the behavior of links: open in the current web broswer tab or in a new tab +* MathJax support +* _Underscore_ +* Control of the behavior of links: open in the current web broswer tab or in a new tab How to use jemdoc+MathJax ------------------------- @@ -28,7 +28,7 @@ Disclaimer ---------- I implemented the new features in jemdoc+MathJax only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) -- Wonseok Shin +Wonseok Shin README of the original jemdoc ----------------------------- From 1e9af6f410ddac788343703836a98373019d0017 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 16:15:52 -0700 Subject: [PATCH 23/52] README.md is updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f6db54c..fbd33bc 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ jemdoc is a light text-based markup language designed for creating websites. Se jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://www.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. -Additional features -------------------- +Additional features introduced in jemdoc+MathJax on top of the original jemdoc +------------------------------------------------------------------------------ * MathJax support * _Underscore_ * Control of the behavior of links: open in the current web broswer tab or in a new tab From 0cf645302fde28fbdee14bfff0721485fc6541b7 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 16:22:59 -0700 Subject: [PATCH 24/52] README.md is simplified --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbd33bc..710aa90 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ jemdoc is a light text-based markup language designed for creating websites. Se jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://www.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. -Additional features introduced in jemdoc+MathJax on top of the original jemdoc ------------------------------------------------------------------------------- +What's new in jemdoc+MathJax +-------------------------------------- * MathJax support * _Underscore_ * Control of the behavior of links: open in the current web broswer tab or in a new tab From 3236beffa4207126ea672a54efba8655399fcc30 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 20:08:50 -0700 Subject: [PATCH 25/52] README.md is updated --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 710aa90..ddd134d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc What's new in jemdoc+MathJax -------------------------------------- * MathJax support -* _Underscore_ +* Underscore * Control of the behavior of links: open in the current web broswer tab or in a new tab How to use jemdoc+MathJax From 99da6f754373e6511044d326c4c48f413a55aec7 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 20:11:45 -0700 Subject: [PATCH 26/52] README.md is updated --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddd134d..2eec1cd 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc What's new in jemdoc+MathJax -------------------------------------- -* MathJax support -* Underscore -* Control of the behavior of links: open in the current web broswer tab or in a new tab +- MathJax support +- Underscore +- Control of the behavior of links: open in the current web broswer tab or in a new tab How to use jemdoc+MathJax ------------------------- From 4603349db48c9f6d0372198065efef08087bafc9 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 22 Apr 2014 20:18:30 -0700 Subject: [PATCH 27/52] README.md is update --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 2eec1cd..c57d58c 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,7 @@ Once you download jemdoc+MathJax, you can install and use it like the original j The usage of the additional features implemented in jemdoc+MathJax can be found in example/ directory in this package. The directory contains jemdoc source files that create an example website that demonstrates the additional features. To build the website, execute the following command in this example/ directory: -``` -../jemdoc -c mysite.conf *.jemdoc -``` + ../jemdoc -c mysite.conf *.jemdoc This generates a few HTML files, which you can open in any web browser to see the results. From c9ceff41c3901ac6f34858b7844a336d96299851 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Thu, 1 May 2014 00:45:54 -0700 Subject: [PATCH 28/52] The link to the GitHub page is corrected --- jemdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 8fd7f64..9e9203b 100755 --- a/jemdoc +++ b/jemdoc @@ -252,7 +252,7 @@ def standardconf(): [lastupdated] - Page generated |, by jemdoc+MathJax. + Page generated |, by jemdoc+MathJax. [sourcelink] (source) From 1547f6e92038458fcc7f260fe52fb2d2c40b724f Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Sun, 15 Jun 2014 02:51:29 -0700 Subject: [PATCH 29/52] README.md is updated --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c57d58c..b8c9833 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ MathJax configuration is done in mysite.conf. Change mysite.conf to control the Disclaimer ---------- -I implemented the new features in jemdoc+MathJax only for my convenience, so in the development I focused on "making them just work". Therefore, the modification is messy and probably contains lots of errors. Hopefully in the future the original jemdoc developer will agree on the usefulness of those features and spend some time himself to figure out how to adopt them in the official jemdoc release in an elegant way :-) +In implementing the new features in jemdoc+MathJax, I focused on "making them just work", so I should admit that my implementations are not the most elegant ones. Also, even though several users and I find jemdoc+MathJax is quite stable, it may contain some errors. Wonseok Shin From f6c777e8a7500024c7cd897cfb0c8bdce81562ed Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Sun, 15 Jun 2014 20:02:51 -0700 Subject: [PATCH 30/52] README.md is updated --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8c9833..6810e11 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ MathJax configuration is done in mysite.conf. Change mysite.conf to control the Disclaimer ---------- -In implementing the new features in jemdoc+MathJax, I focused on "making them just work", so I should admit that my implementations are not the most elegant ones. Also, even though several users and I find jemdoc+MathJax is quite stable, it may contain some errors. +While implementing the new features in jemdoc+MathJax, I focused on "making them just work", so I should admit that my implementations are not the most elegant ones. Also, even though several users and I find jemdoc+MathJax is quite stable, it may contain some errors. Wonseok Shin From a5df609506d266db5ecd27dee6c0ec0aa0f843b6 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Thu, 26 Jun 2014 20:05:27 +0900 Subject: [PATCH 31/52] Webpage address is changed from www.stanford.edu to web.stanford.edu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6810e11..4e80e52 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ jemdoc+MathJax ============== jemdoc is a light text-based markup language designed for creating websites. See http://jemdoc.jaboc.net/ for more information and the detailed usage of jemdoc. -jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://www.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. +jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. What's new in jemdoc+MathJax -------------------------------------- From f083a18e44c8cc85b634b140a2de61efab8f5721 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 22 Aug 2014 08:52:48 -0700 Subject: [PATCH 32/52] README.md is updated --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e80e52..57e768f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ MathJax configuration is done in mysite.conf. Change mysite.conf to control the Disclaimer ---------- -While implementing the new features in jemdoc+MathJax, I focused on "making them just work", so I should admit that my implementations are not the most elegant ones. Also, even though several users and I find jemdoc+MathJax is quite stable, it may contain some errors. +The focus of the implementation of the additional features was to "make them just work," so the implementation is suboptimal, both in terms of performance and style. + +Still, several users and I find jemdoc+MathJax is quite stable and does the job correctly :-) Wonseok Shin From 33bc6eba1dbd8e7330a2c020960268e4d3b57cd8 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Tue, 3 Mar 2015 18:44:16 -0800 Subject: [PATCH 33/52] MathJax Java script location is changed from http://... to https://... --- example/mysite.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/mysite.conf b/example/mysite.conf index 34d341e..e0cac86 100644 --- a/example/mysite.conf +++ b/example/mysite.conf @@ -1,5 +1,5 @@ [bodyend] - + + + From 487b09448a78445b769509983277d7b04234f264 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Mon, 8 Jun 2015 16:25:19 -0700 Subject: [PATCH 38/52] CSS files are correctly indented --- css/example.css | 18 +++++----- css/exp.css | 70 +++++++++++++++++++------------------- css/jacob.css | 2 +- css/jemdoc.css | 55 ++++++++++++++++-------------- css/page.css | 50 +++++++++++++-------------- css/prob.css | 34 +++++++++---------- css/table.css | 4 +-- css/white.css | 84 +++++++++++++++++++++++----------------------- example/jemdoc.css | 55 ++++++++++++++++-------------- 9 files changed, 189 insertions(+), 183 deletions(-) diff --git a/css/example.css b/css/example.css index e206d6a..997cc5a 100644 --- a/css/example.css +++ b/css/example.css @@ -1,25 +1,25 @@ table.dual-mode { - padding: 0; - margin-top, margin-bottom: 0.5em; + padding: 0; + margin-top, margin-bottom: 0.5em; border-width: 0; } table.dual-mode tr { - vertical-align: top; + vertical-align: top; } -table.dual-mode h1, tr h2{ - padding-top: 0em; +table.dual-mode h1, tr h2 { + padding-top: 0em; margin-top: 0; } td { - text-align: left; - border: none; + text-align: left; + border: none; } td.rightcell tt { - background: none; + background: none; } td.rightcell div.blockcontent { @@ -35,7 +35,7 @@ td.rightcell div.codeblock { td.leftcell { padding-right: 10px; - padding-top: 10px; + padding-top: 10px; width: 50%; } diff --git a/css/exp.css b/css/exp.css index 6623186..ac3d57e 100644 --- a/css/exp.css +++ b/css/exp.css @@ -1,84 +1,84 @@ body { - font: 80% Verdana, sans-serif; + font: 80% Verdana, sans-serif; } pre, tt { - font-size: 110%; + font-size: 110%; } tt { - background: #ffffdd; - color: #000050; + background: #ffffdd; + color: #000050; } pre { - color: black; + color: black; } a { - border-bottom: 1px solid #bbbbbb; + border-bottom: 1px solid #bbbbbb; } a:hover { - border-bottom: 1px solid #bbbbbb; + border-bottom: 1px solid #bbbbbb; } h1 { - font-size: 150%; - border: none; + font-size: 150%; + border: none; } h2 { - font-size: 115%; - border: none; + font-size: 115%; + border: none; } h3 { - font-size: 100%; - border: none; + font-size: 100%; + border: none; } div.infoblock > div.blockcontent { - background: #ffffdd; + background: #ffffdd; } div.blockcontent { - padding-left: 10px; - padding-right: 10px; - padding-top: 6px; - padding-bottom: 7px; + padding-left: 10px; + padding-right: 10px; + padding-top: 6px; + padding-bottom: 7px; } p { - line-height: 1.5em; + line-height: 1.5em; margin-bottom: 1.2em; } #layout-menu { - padding-left: 15px; - line-height: 1.7em; - text-align: right; - padding-top: 0.5em; + padding-left: 15px; + line-height: 1.7em; + text-align: right; + padding-top: 0.5em; } b { - font-weight: normal; + font-weight: normal; } p b { - font-style: italic; + font-style: italic; } div.menu-item { - padding-left: 0; - text-indent: 0; - padding-bottom: 2px; + padding-left: 0; + text-indent: 0; + padding-bottom: 2px; } #layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover { - color: black; + color: black; border-bottom: 1px gray solid; } @@ -88,13 +88,13 @@ div.menu-item { div#footer { border-top: 1px solid #e0e0e0; - font-size: 80%; - padding-bottom: 0; + font-size: 80%; + padding-bottom: 0; } div#footer a { color: #aaaaaa; - border-bottom: 1px solid #cccccc; + border-bottom: 1px solid #cccccc; } #fwtitle div#toptitle { @@ -103,7 +103,7 @@ div#footer a { #layout-content { - padding-top: 1.3em; - padding-left: 30px; - padding-right: 30px; + padding-top: 1.3em; + padding-left: 30px; + padding-right: 30px; } diff --git a/css/jacob.css b/css/jacob.css index 52e7902..2ba613b 100644 --- a/css/jacob.css +++ b/css/jacob.css @@ -34,5 +34,5 @@ div.blockcontent { } div#footer-text { - padding-bottom: 8px; + padding-bottom: 8px; } diff --git a/css/jemdoc.css b/css/jemdoc.css index 00e05f0..aa9923d 100644 --- a/css/jemdoc.css +++ b/css/jemdoc.css @@ -1,9 +1,9 @@ /* Default css file for jemdoc. */ table#tlayout { - border: none; - border-collapse: separate; - background: white; + border: none; + border-collapse: separate; + background: white; } body { @@ -22,23 +22,23 @@ body { font-size: 1.0em; width: auto; white-space: nowrap; - text-align: left; - vertical-align: top; + text-align: left; + vertical-align: top; } #layout-menu td { background: #f4f4f4; - vertical-align: top; + vertical-align: top; } #layout-content { padding-top: 0.0em; padding-left: 1.0em; padding-right: 1.0em; - border: none; - background: white; - text-align: left; - vertical-align: top; + border: none; + background: white; + text-align: left; + vertical-align: top; } #layout-menu a { @@ -47,7 +47,7 @@ body { } tt { - background: #ffffdd; + background: #ffffdd; } pre, tt { @@ -136,7 +136,7 @@ h2 { } h2 + h3 { - padding-top: 0.2em; + padding-top: 0.2em; } h3 { @@ -297,7 +297,10 @@ span.comment, span.comment > *, span.string, span.string > * { } @media print { - #layout-menu { display: none; } + #layout-menu { + display: none; + } + } #fwtitle { @@ -336,32 +339,32 @@ img.eqwl { } table { - border: 2px solid black; - border-collapse: collapse; + border: 2px solid black; + border-collapse: collapse; } td { - padding: 2px; - padding-left: 0.5em; - padding-right: 0.5em; - text-align: center; - border: 1px solid gray; + padding: 2px; + padding-left: 0.5em; + padding-right: 0.5em; + text-align: center; + border: 1px solid gray; } table + table { - margin-top: 1em; + margin-top: 1em; } tr.heading { - font-weight: bold; - border-bottom: 2px solid black; + font-weight: bold; + border-bottom: 2px solid black; } img { - border: none; + border: none; } table.imgtable, table.imgtable td { - border: none; - text-align: left; + border: none; + text-align: left; } diff --git a/css/page.css b/css/page.css index dcbbe68..65c25b9 100644 --- a/css/page.css +++ b/css/page.css @@ -1,47 +1,47 @@ -#fwtitle { - margin: 0; - padding: 0; +#fwtitle { + margin: 0; + padding: 0; } #fwtitle div#toptitle { - background-color: #303050; - padding: 1em; - margin: 0; - border: none; + background-color: #303050; + padding: 1em; + margin: 0; + border: none; } div#toptitle h1 { - margin-top: 0.1em; + margin-top: 0.1em; } #fwtitle div#toptitle h1, div#subtitle, div#subtitle a { - color: white; - font-weight: normal; - text-align: left; + color: white; + font-weight: normal; + text-align: left; } #layout-menu { - border: none; - border-right: 1px dashed #aaaaaa; - margin: 0; - padding-top: 0; + border: none; + border-right: 1px dashed #aaaaaa; + margin: 0; + padding-top: 0; } div.menu-category { - border-bottom: none; - padding-bottom: 0; + border-bottom: none; + padding-bottom: 0; } #layout-content { - border: none; - padding: 8px; - padding-left: 16px; - padding-right: 16px; - padding-bottom: 0; - margin: 0; + border: none; + padding: 8px; + padding-left: 16px; + padding-right: 16px; + padding-bottom: 0; + margin: 0; } body { - padding: 0; - padding-bottom: 8px; + padding: 0; + padding-bottom: 8px; } diff --git a/css/prob.css b/css/prob.css index f19758c..e06d12e 100644 --- a/css/prob.css +++ b/css/prob.css @@ -1,56 +1,56 @@ div.codeblock pre { - font-size: 0.2em; + font-size: 0.2em; } p b { - font-style: normal; - font-weight: bold; + font-style: normal; + font-weight: bold; } td.c1 { - text-align: right; + text-align: right; } td.c2 { - text-align: left; - font-weight: bold; + text-align: left; + font-weight: bold; } table { - border: 1px solid black; - margin-top: 0.5em; - margin-bottom: 1em; + border: 1px solid black; + margin-top: 0.5em; + margin-bottom: 1em; } p + table { - margin-top: -0.3em; + margin-top: -0.3em; } a.imglink { - border: none; + border: none; } /* Exceedingly lame hack to eliminate borders with figure images. */ a.imglink > img { - margin-left: -55px; + margin-left: -55px; } .red { - color: red; + color: red; } .green { - color: green; + color: green; } h1 { - padding-top: 1em; + padding-top: 1em; } table#allprobs td { - font-weight: normal; + font-weight: normal; } table#allprobs td.c1, table#allprobs tr.r1 td, table#allprobs tr.r1 td.c1 { - font-weight: bold; + font-weight: bold; } diff --git a/css/table.css b/css/table.css index ee59050..9c1be3f 100644 --- a/css/table.css +++ b/css/table.css @@ -1,4 +1,4 @@ #countries tr.r1 { - border-bottom: 2px solid black; - font-weight: bold; + border-bottom: 2px solid black; + font-weight: bold; } diff --git a/css/white.css b/css/white.css index ec4dec9..4ee5dd2 100644 --- a/css/white.css +++ b/css/white.css @@ -1,52 +1,52 @@ body { - font: 80% Verdana; - margin-left: 2em; - margin-top: 1em; + font: 80% Verdana; + margin-left: 2em; + margin-top: 1em; } pre, tt { - font-size: 110%; - background: #ffffdd; + font-size: 110%; + background: #ffffdd; } tt { - color: #700000; + color: #700000; } pre { - color: black; + color: black; } a { - border-bottom: 1px solid #bbbbbb; - color: black; + border-bottom: 1px solid #bbbbbb; + color: black; } h1 { - font-size: 150%; - border: none; + font-size: 150%; + border: none; } h2 { - font-size: 115%; - border: none; + font-size: 115%; + border: none; } h3 { - font-size: 100%; - border: none; + font-size: 100%; + border: none; } h1, h2, h3, div.blocktitle { - color: #990000; + color: #990000; } div.blockcontent { - border: none; + border: none; } div.infoblock > div.blockcontent { - background: #ffffdd; + background: #ffffdd; } div.codeblock > div.blockcontent, div.blockcontent pre { @@ -54,48 +54,48 @@ div.codeblock > div.blockcontent, div.blockcontent pre { } body, p { - line-height: 1.5em; + line-height: 1.5em; margin-bottom: 1.2em; } #layout-menu { - padding-left: 20px; - padding-right: 20px; - background: none; - text-align: right; - border: none; - padding-top: 3.0em; + padding-left: 20px; + padding-right: 20px; + background: none; + text-align: right; + border: none; + padding-top: 3.0em; } #layout-content { - padding-left: 25px; - padding-top: 1em; - width: 600px; + padding-left: 25px; + padding-top: 1em; + width: 600px; } b { - font-weight: normal; + font-weight: normal; } p b { - font-style: italic; + font-style: italic; } div.menu-category { - border: none; - border-bottom: 1px solid - margin-top: 1.0em; - padding-bottom: 0; + border: none; + border-bottom: 1px solid + margin-top: 1.0em; + padding-bottom: 0; } div.menu-item { - padding-left: 0; - text-indent: 0; - padding-bottom: 2px; + padding-left: 0; + text-indent: 0; + padding-bottom: 2px; } #layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover { - color: black; + color: black; border-bottom: 1px gray solid; } @@ -106,16 +106,16 @@ div.menu-item { div#footer { border-top: 1px solid #e0e0e0; - font-size: 80%; - padding-bottom: none; + font-size: 80%; + padding-bottom: none; } div#footer a { color: #bbbbbb; - border-bottom: 1px solid #cccccc; + border-bottom: 1px solid #cccccc; } div#toptitle { - border: none; + border: none; } diff --git a/example/jemdoc.css b/example/jemdoc.css index 9fe8685..def76bb 100644 --- a/example/jemdoc.css +++ b/example/jemdoc.css @@ -1,9 +1,9 @@ /* Default css file for jemdoc. */ table#tlayout { - border: none; - border-collapse: separate; - background: white; + border: none; + border-collapse: separate; + background: white; } body { @@ -22,23 +22,23 @@ body { font-size: 1.0em; width: auto; white-space: nowrap; - text-align: left; - vertical-align: top; + text-align: left; + vertical-align: top; } #layout-menu td { background: #f4f4f4; - vertical-align: top; + vertical-align: top; } #layout-content { padding-top: 0.0em; padding-left: 1.0em; padding-right: 1.0em; - border: none; - background: white; - text-align: left; - vertical-align: top; + border: none; + background: white; + text-align: left; + vertical-align: top; min-width: 800px; width: 800px; } @@ -49,7 +49,7 @@ body { } tt { - background: #ffffdd; + background: #ffffdd; } pre, tt { @@ -138,7 +138,7 @@ h2 { } h2 + h3 { - padding-top: 0.2em; + padding-top: 0.2em; } h3 { @@ -299,7 +299,10 @@ span.comment, span.comment > *, span.string, span.string > * { } @media print { - #layout-menu { display: none; } + #layout-menu { + display: none; + } + } #fwtitle { @@ -338,32 +341,32 @@ img.eqwl { } table { - border: 2px solid black; - border-collapse: collapse; + border: 2px solid black; + border-collapse: collapse; } td { - padding: 2px; - padding-left: 0.5em; - padding-right: 0.5em; - text-align: center; - border: 1px solid gray; + padding: 2px; + padding-left: 0.5em; + padding-right: 0.5em; + text-align: center; + border: 1px solid gray; } table + table { - margin-top: 1em; + margin-top: 1em; } tr.heading { - font-weight: bold; - border-bottom: 2px solid black; + font-weight: bold; + border-bottom: 2px solid black; } img { - border: none; + border: none; } table.imgtable, table.imgtable td { - border: none; - text-align: left; + border: none; + text-align: left; } From 5d95ff5b52205270a79d2b442d81db6d4b143830 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Wed, 6 Jan 2016 15:47:58 -0500 Subject: [PATCH 39/52] Now jemdoc+MathJax works on both Python 2 and 3 --- README.md | 7 ++++++- jemdoc | 49 ++++++++++++++++++++++++++----------------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 57e768f..5f552e3 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,16 @@ jemdoc is a light text-based markup language designed for creating websites. Se jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. +System requirements +------------------- +Python 2 or Python 3. (Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes to support Python 3.) + What's new in jemdoc+MathJax --------------------------------------- +---------------------------- - MathJax support - Underscore - Control of the behavior of links: open in the current web broswer tab or in a new tab +- Works on both Python 2 and 3 How to use jemdoc+MathJax ------------------------- diff --git a/jemdoc b/jemdoc index 2406856..f36a210 100755 --- a/jemdoc +++ b/jemdoc @@ -22,25 +22,26 @@ # latexmath2png, by Kamil Kisiel (kamil@kamikisiel.net). # +from __future__ import print_function import sys import os import re import time -import StringIO +import io from subprocess import * import tempfile def info(): - print __doc__ - print 'Platform: ' + sys.platform + '.' - print 'Python: %s, located at %s.' % (sys.version[:5], sys.executable) - print 'Equation support:', + print(__doc__) + print('Platform: ' + sys.platform + '.') + print('Python: %s, located at %s.' % (sys.version[:5], sys.executable)) + print('Equation support:', end=' ') (supported, message) = testeqsupport() if supported: - print 'yes.' + print('yes.') else: - print 'no.' - print message + print('no.') + print(message) def testeqsupport(): supported = True @@ -127,7 +128,7 @@ def showhelp(): else: b += l - print b + print(b) def standardconf(): a = """[firstbit] @@ -260,7 +261,9 @@ def standardconf(): """ b = '' for l in a.splitlines(True): - if l.startswith(' '): + if l.startswith(' #'): + continue + elif l.startswith(' '): b += l[2:] else: b += l @@ -287,13 +290,13 @@ def readnoncomment(f): elif l[0] == '#': # jem: be a little more generous with the comments we accept? return readnoncomment(f) else: - return l.rstrip() + '\n' # leave just one \n and no spaces etc. + return l.rstrip().decode() + '\n' # leave just one \n and no spaces etc. def parseconf(cns): syntax = {} warn = False # jem. make configurable? # manually add the defaults as a file handle. - fs = [StringIO.StringIO(standardconf())] + fs = [io.BytesIO(standardconf().encode())] for sname in cns: fs.append(open(sname, 'rb')) @@ -369,7 +372,7 @@ def insertmenuitems(f, mname, current, prefix): m.close() def out(f, s): - f.write(s) + f.write(s.encode('utf-8')) def mathjaxussub(link): link = link.replace('_', 'UNDERSCORE65358') @@ -436,7 +439,7 @@ def hb(f, tag, content1, content2=None, content3=None): def pc(f, ditchcomments=True): """Peeks at next character in the file.""" # Should only be used to look at the first character of a new line. - c = f.inf.read(1) + c = f.inf.read(1).decode('cp1252') if c: # only undo forward movement if we're not at the end. if ditchcomments and c == '#': l = nl(f) @@ -472,7 +475,7 @@ def doincludes(f, l): def nl(f, withcount=False, codemode=False): """Get input file line.""" - s = f.inf.readline() + s = f.inf.readline().decode('utf-8') if not s and f.otherfiles: f.nextfile() return nl(f, withcount, codemode) @@ -990,7 +993,7 @@ def geneq(f, eq, dpi, wl, outname): if os.path.exists(eqname) and eqname in eqdepths: return (eqdepths[eqname], eqname) except IOError: - print 'eqdepthcache read failed.' + print('eqdepthcache read failed.') # Open tex file. tempdir = tempfile.gettempdir() @@ -1000,7 +1003,7 @@ def geneq(f, eq, dpi, wl, outname): preamble = '\documentclass{article}\n' for p in f.eqpackages: - preamble += '\usepackage{%s}\n' % p + preamble += '\\usepackage{%s}\n' % p for p in f.texlines: # Replace \{ and \} in p with { and }. # XXX hack. @@ -1027,7 +1030,7 @@ def geneq(f, eq, dpi, wl, outname): rc = p.wait() if rc != 0: for l in p.stdout.readlines(): - print ' ' + l.rstrip() + print(' ' + l.rstrip()) exts.remove('.tex') raise Exception('latex error') @@ -1037,7 +1040,7 @@ def geneq(f, eq, dpi, wl, outname): p = Popen(dvicmd, shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() if rc != 0: - print p.stderr.readlines() + print(p.stderr.readlines()) raise Exception('dvipng error') depth = int(p.stdout.readlines()[-1].split('=')[-1]) finally: @@ -1054,7 +1057,7 @@ def geneq(f, eq, dpi, wl, outname): dc.write(eqname + ' ' + str(depth) + '\n') dc.close() except IOError: - print 'eqdepthcache update failed.' + print('eqdepthcache update failed.') return (depth, eqname) def dashlist(f, ordered=False): @@ -1194,7 +1197,7 @@ def codeblock(f, g): if raw: return elif ext_prog: - print 'filtering through %s...' % ext_prog + print('filtering through %s...' % ext_prog) output,_ = Popen(ext_prog, shell=True, stdin=PIPE, stdout=PIPE).communicate(buff) @@ -1234,7 +1237,7 @@ def procfile(f): js = [] title = None while pc(f, False) == '#': - l = f.inf.readline() + l = f.inf.readline().decode() f.linenum += 1 if doincludes(f, l[1:]): continue @@ -1549,7 +1552,7 @@ def main(): showhelp() raise SystemExit if sys.argv[1] == '--show-config': - print standardconf() + print(standardconf()) raise SystemExit if sys.argv[1] == '--version': info() From 9717b9dbfee80a5675eeae7447b2f7ef16a07635 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Wed, 6 Jan 2016 15:58:31 -0500 Subject: [PATCH 40/52] README.md is updated --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f552e3..b07c9e1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc System requirements ------------------- -Python 2 or Python 3. (Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes to support Python 3.) +Python 2 or Python 3 +(Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes to support Python 3.) What's new in jemdoc+MathJax ---------------------------- From 2fed9bbd15c3a1afcd64bb9e95ce2d161dcf16d8 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Wed, 6 Jan 2016 15:59:04 -0500 Subject: [PATCH 41/52] README.md is updated --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b07c9e1..ac2f9ef 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc System requirements ------------------- Python 2 or Python 3 + (Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes to support Python 3.) What's new in jemdoc+MathJax From fa2a57d70152eb4a189f34410f92b795e309da04 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 29 Jan 2016 18:23:51 -0500 Subject: [PATCH 42/52] Unicode errors are fixed; works on both Python 2 and 3 --- jemdoc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/jemdoc b/jemdoc index f36a210..3c72da5 100755 --- a/jemdoc +++ b/jemdoc @@ -29,6 +29,7 @@ import re import time import io from subprocess import * +from types import * import tempfile def info(): @@ -86,7 +87,7 @@ class controlstruct(object): def pushfile(self, newfile): self.otherfiles.insert(0, self.inf) - self.inf = open(newfile, 'rb') + self.inf = io.open(newfile, 'rb') def nextfile(self): self.inf.close() @@ -284,21 +285,21 @@ def raisejandal(msg, line=0): raise JandalError(s) def readnoncomment(f): - l = f.readline() + l = f.readline().decode('utf-8') if l == '': return l elif l[0] == '#': # jem: be a little more generous with the comments we accept? return readnoncomment(f) else: - return l.rstrip().decode() + '\n' # leave just one \n and no spaces etc. + return l.rstrip() + '\n' # leave just one \n and no spaces etc. def parseconf(cns): syntax = {} warn = False # jem. make configurable? # manually add the defaults as a file handle. - fs = [io.BytesIO(standardconf().encode())] + fs = [io.BytesIO(standardconf().encode('utf-8'))] for sname in cns: - fs.append(open(sname, 'rb')) + fs.append(io.open(sname, 'rb')) for f in fs: while pc(controlstruct(f)) != '': @@ -321,7 +322,7 @@ def parseconf(cns): return syntax def insertmenuitems(f, mname, current, prefix): - m = open(mname, 'rb') + m = io.open(mname, 'rb') while pc(controlstruct(m)) != '': l = readnoncomment(m) l = l.strip() @@ -372,7 +373,11 @@ def insertmenuitems(f, mname, current, prefix): m.close() def out(f, s): - f.write(s.encode('utf-8')) +# print(type(s)) + if sys.version_info[0] == 2 and type(s) is StringType: + f.write(s.decode('utf-8')) + else: + f.write(s) def mathjaxussub(link): link = link.replace('_', 'UNDERSCORE65358') @@ -463,7 +468,7 @@ def doincludes(f, l): ir = 'includeraw{' i = 'include{' if l.startswith(ir): - nf = open(l[len(ir):-2], 'rb') + nf = io.open(l[len(ir):-2], 'rb') f.outf.write(nf.read()) nf.close() elif l.startswith(i): @@ -984,7 +989,7 @@ def geneq(f, eq, dpi, wl, outname): eqdepths = {} if f.eqcache: try: - dc = open(os.path.join(f.eqdir, '.eqdepthcache'), 'rb') + dc = io.open(os.path.join(f.eqdir, '.eqdepthcache'), 'rb') for l in dc: a = l.split() eqdepths[a[0]] = int(a[1]) @@ -1053,7 +1058,7 @@ def geneq(f, eq, dpi, wl, outname): # Update the cache if we're using it. if f.eqcache and eqname not in eqdepths: try: - dc = open(os.path.join(f.eqdir, '.eqdepthcache'), 'ab') + dc = io.open(os.path.join(f.eqdir, '.eqdepthcache'), 'ab') dc.write(eqname + ' ' + str(depth) + '\n') dc.close() except IOError: @@ -1602,8 +1607,8 @@ def main(): else: thisout = outname - infile = open(inname, 'rUb') - outfile = open(thisout, 'w') + infile = io.open(inname, 'rUb') + outfile = io.open(thisout, 'w') f = controlstruct(infile, outfile, conf, inname) procfile(f) From 8eb3dc1b07b6eb77d6e87069c263ba87b1f488f5 Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Fri, 29 Jan 2016 18:34:05 -0500 Subject: [PATCH 43/52] UTF-8 encoding/decoding is specified explicitly --- jemdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jemdoc b/jemdoc index 3c72da5..00ab158 100755 --- a/jemdoc +++ b/jemdoc @@ -1242,7 +1242,7 @@ def procfile(f): js = [] title = None while pc(f, False) == '#': - l = f.inf.readline().decode() + l = f.inf.readline().decode('utf-8') f.linenum += 1 if doincludes(f, l[1:]): continue From eee30413663299c0ddcfcaf340bb254f50a3aceb Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Mon, 15 Aug 2016 21:04:33 -0400 Subject: [PATCH 44/52] Now correctly handles matrix rows beginning with minus inside inline equation blocks --- jemdoc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/jemdoc b/jemdoc index 00ab158..f9f77a5 100755 --- a/jemdoc +++ b/jemdoc @@ -523,8 +523,26 @@ def np(f, withcount=False, eatblanks=True): else: s = nl(f) - while pc(f) not in ('\n', '-', '.', ':', '', '=', '~', '{', '\\(', '\\)'): - s += nl(f) + # Determine if the current line has an open inline equation block or not. + r = re.compile(r'(?, < in LaTeX code with &, >, <. Is this necessary? r = re.compile(r"(? Date: Wed, 17 Aug 2016 15:28:01 -0400 Subject: [PATCH 45/52] README.md is updated to emphasize the way to fetch MathJax engine --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ac2f9ef..92059ad 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ jemdoc+MathJax ============== jemdoc is a light text-based markup language designed for creating websites. See http://jemdoc.jaboc.net/ for more information and the detailed usage of jemdoc. -jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax, but the equations will be rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. +jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax (and therefore no need to make any changes in your jemdoc scripts), but the equations will be rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. System requirements ------------------- Python 2 or Python 3 -(Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes to support Python 3.) +(Many thanks to [Ganesh Ajjanagadde](http://www.mit.edu/~gajjanag/), who made most of the changes for Python 3 compatibility.) What's new in jemdoc+MathJax ---------------------------- @@ -19,15 +19,19 @@ What's new in jemdoc+MathJax How to use jemdoc+MathJax ------------------------- -Once you download jemdoc+MathJax, you can install and use it like the original jemdoc. See the [jemdoc user guide](http://jemdoc.jaboc.net/using.html), expecially the [example page](http://jemdoc.jaboc.net/example.html). +The only major difference from the original jemdoc in usage is the mechanism to fetch the javascript engine for MathJax. The recommended way of doing this is to specify the URL of the javascript engine inside a configuration file (`mysite.conf` in the following example) and to provide the file to the jemdoc executable as -The usage of the additional features implemented in jemdoc+MathJax can be found in example/ directory in this package. The directory contains jemdoc source files that create an example website that demonstrates the additional features. To build the website, execute the following command in this example/ directory: + jemdoc -c mysite.conf YOUR_JEMDOC_SCRIPT.jemdoc - ../jemdoc -c mysite.conf *.jemdoc +An example `mysite.conf` can be found in the `example/` directory. + +The `example/` directory also contains jemdoc script files that demonstrate the usage of the additional features implemented in jemdoc+MathJax. You can build a website out of these jemdoc scripts by executing the following command inside the `example/` directory: -This generates a few HTML files, which you can open in any web browser to see the results. + ../jemdoc -c mysite.conf *.jemdoc + +To see the resulting website, open any HTML files generated by the above command inside a web browser. -MathJax configuration is done in mysite.conf. Change mysite.conf to control the behavior of MathJax. +Except for the MathJax support and the few additional features mentioned previously, jemdoc+MathJax is exactly the same as the original jemdoc. To learn the usage of the original jemdoc, see the [jemdoc user guide](http://jemdoc.jaboc.net/using.html), expecially the [example page](http://jemdoc.jaboc.net/example.html). Disclaimer ---------- From b3f794b6e8fa4575cbb1365e737acb235fcd8b9b Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Wed, 17 Aug 2016 15:34:16 -0400 Subject: [PATCH 46/52] README.md is updated to emphasize the way to fetch MathJax engine --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 92059ad..959afa3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ jemdoc+MathJax ============== -jemdoc is a light text-based markup language designed for creating websites. See http://jemdoc.jaboc.net/ for more information and the detailed usage of jemdoc. +*jemdoc* is a light text-based markup language designed for creating websites. See http://jemdoc.jaboc.net/ for more information and the detailed usage of jemdoc. -jemdoc+MathJax adds the MathJax support to jemdoc. You can use the same jemdoc syntax (and therefore no need to make any changes in your jemdoc scripts), but the equations will be rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. +*jemdoc+MathJax* adds the MathJax support to jemdoc. You can use the same jemdoc syntax (and therefore no need to make any changes in your jemdoc scripts if you are an original jemdoc user), but the equations will be beautifully rendered by MathJax. See http://web.stanford.edu/~wsshin/jemdoc+mathjax.html for more information and examples. System requirements ------------------- @@ -31,7 +31,7 @@ The `example/` directory also contains jemdoc script files that demonstrate the To see the resulting website, open any HTML files generated by the above command inside a web browser. -Except for the MathJax support and the few additional features mentioned previously, jemdoc+MathJax is exactly the same as the original jemdoc. To learn the usage of the original jemdoc, see the [jemdoc user guide](http://jemdoc.jaboc.net/using.html), expecially the [example page](http://jemdoc.jaboc.net/example.html). +Except for the MathJax support and the few additional features mentioned previously, jemdoc+MathJax is almost exactly the same as the original jemdoc. To learn the usage of the original jemdoc, see the [jemdoc user guide](http://jemdoc.jaboc.net/using.html), expecially the [example page](http://jemdoc.jaboc.net/example.html). Disclaimer ---------- From fa10849fa7115311fc2dbec91384d19a2d669a3f Mon Sep 17 00:00:00 2001 From: Wonseok Shin Date: Mon, 10 Jul 2017 22:47:55 -0400 Subject: [PATCH 47/52] Update CDN description in example/mysite.conf --- example/mysite.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/mysite.conf b/example/mysite.conf index 4d92ac0..0aed8f5 100644 --- a/example/mysite.conf +++ b/example/mysite.conf @@ -1,6 +1,6 @@ [bodystart] -