leegao / readme2tex Goto Github PK
View Code? Open in Web Editor NEWRenders TeXy Math for Github Readmes
License: MIT License
Renders TeXy Math for Github Readmes
License: MIT License
So something like
meh
This `inline code pre` will not work.
generated by
<p>meh<p>
This `inline code pre` will not work.
won't break formatting for all subsequent images.
Seems like the img tags have align=middle
instead of align="middle"
. Although this works on the github readme, it does not work on the corresponding github.io page. Manually changing them all to align="middle"
seems to work.
My raw files are stored on raw.githubusercontent.com
instead of rawgit.com
.
For example, some svg would be saved here:
https://raw.githubusercontent.com/RobRomijnders/ssl_graph/master/svgs/c9ea84eb1460d2895e0cf5125bd7f7b5.svg
But readme2tex
would refer to the image as being here
https://rawgit.com/RobRomijnders/ssl_graph/master/svgs/c9ea84eb1460d2895e0cf5125bd7f7b5.svg
Might this be due to an update on github's side? If so, could be include it as a flag?
First, thanks for writing this!
Second, after I generate via
python -m readme2tex --output README.md --readme .README.md --branch master --svgdir 'docs/gfx' --nocdn --rerender --usepackage 'tikz' --usepackage 'algorithm' --usepackage 'algpseudocode' --usepackage 'fancybox'
I get a README.md
with svg image links all ending in ?invert_in_darkmode
. If I push these to github, the images are broken. However, if I remove ?invert_in_darkmode
from the generated document everything works fine.
Another point that might be relevant, this is for a private repo.
The path fails to correctly parse the username when the user is using a ssh as their first remote. This can be easily fixed by deleting a single '/' character from the parsing snippet in line 294 of render.py
. As both http and ssh have a .com? right before the username, where ? is either "/" for http or "@" for ssh.
start = giturl.find('.com') + 5
When I convert a markdown file with pandoc to github flavor markdown with the -t gfm
option, $$ ... $$
will get converted to \[ ...\]
(not sure why). Any chance of supporting this syntax as well? Multimarkdown appears to have this/a non "$" based syntax for maths as well, for example.
It would be cool to have a github action that each time you commit scans for latex in md files and automatically substitutes them with images
Hi, I'm getting <img src="https://rawgit.com/in [email protected]:parrt/auto-diff-edu/master/images/6177db6fc70d94fdb9dbe1907695fce6.svg?invert_in_darkmode" align=middle width=15.947580000000002pt height=26.76201000000001pt/>.
for an image url.
i'm using
python -m readme2tex --rerender --svgdir images --usepackage physics --output README.md README.tex.md
cool package btw!
I'm not sure what's wrong, tried with sudo in case my user didn't have permissions, same outcome.
$ python3 -m readme2tex --output README1.md README.md
'$n * T_i | n\in \Bbb N + \{0\}$' has warnings during compilation. See /var/folders/3w/b2_16tq53jnfq2kn92fg4mdh0000gs/T/readme2tex-srbuc3i1/01c646718a35875ea8195cf0865d9375
ERROR: can't open file '/var/folders/3w/b2_16tq53jnfq2kn92fg4mdh0000gs/T/readme2tex-srbuc3i1/01c646718a35875ea8195cf0865d9375.dvi' for reading
Traceback (most recent call last):
File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/readme2tex/__main__.py", line 147, in <module>
render(
File "/usr/local/lib/python3.9/site-packages/readme2tex/render.py", line 167, in render
svg, dvi, name = rendertex(engine, equation, packages, temp_dir, block)
File "/usr/local/lib/python3.9/site-packages/readme2tex/render.py", line 43, in rendertex
svg = check_output(
File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['dvisvgm', '-v0', '-a', '-n', '-s', '/var/folders/3w/b2_16tq53jnfq2kn92fg4mdh0000gs/T/readme2tex-srbuc3i1/01c646718a35875ea8195cf0865d9375.dvi']' returned non-zero exit status 252.
$ cat /var/folders/3w/b2_16tq53jnfq2kn92fg4mdh0000gs/T/readme2tex-srbuc3i1/01c646718a35875ea8195cf0865d9375.tex
% processed with readme2tex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\pagestyle{empty}
\geometry{paperwidth=250mm, paperheight=16383pt, left=0pt, top=0pt, textwidth=426pt, marginparsep=20pt, marginparwidth=100pt, textheight=16263pt, footskip=40pt}
\begin{document}
a$n * T_i | n\in \Bbb N + \{0\}$
\end{document}
I'd just like to convert a markdown+tex file without being in git repo. Is this possible? Currently I get this error:
Not in a git repository, please enable --nocdn
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/readme2tex/render.py", line 290, in render
giturl = check_output(['git', 'remote', '-v']).strip().decode('utf-8').splitlines()[0]
File "/opt/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/opt/anaconda3/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'remote', '-v']' returned non-zero exit status 128.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/opt/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/anaconda3/lib/python3.7/site-packages/readme2tex/__main__.py", line 160, in <module>
args.bustcache)
File "/opt/anaconda3/lib/python3.7/site-packages/readme2tex/render.py", line 296, in render
raise Exception("Please specify your github --username and --project.")
Exception: Please specify your github --username and --project.
The following works as expected:
# README
$\newcommand{\f}{\mathbf{f}}
\|\f\|^2$
But if I put newcommand
in a different line this will not work:
# README
$\newcommand{\f}{\mathbf{f}}$
$\|\f\|^2$
Mathjax for example will keep commands persistent through the document. This is very useful if I want to define some macro at the top of the document and use it in a bunch of equations below.
I humbly request this feature.
The same markdown is now rendered differently by github. Going back in time via the commits flow also confirms this. Not sure what the right repro is, but hopeful we can find a way around this.
The directory I was working in was a git repository:
code/coq-typeclass-hierarchy > python -m readme2tex --add-git-hook
Traceback (most recent call last):
File "/nix/store/p4fqqhllhyj90njg2sksz8qrgzlzs193-python-2.7.13/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/nix/store/p4fqqhllhyj90njg2sksz8qrgzlzs193-python-2.7.13/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/nix/store/qgfi4pzf9awf5axakp2f0kj4xf7r7grn-readme2tex/lib/python2.7/site-packages/readme2tex/__main__.py", line 163, in <module>
assert os.path.exists(".git")
AssertionError
Hello, I just installed this package and I tried to complie my README.md.
After I command python -m readme2tex --output result.md README.md
, I got this error message but I don't know how to handle it
'$cost=\sum { { (y-\bar { y } ) }^{ 2 } } +\lambda \sum { { \left| W \right| }^{ 2 } }$' has warnings during compilation. See /var/folders/zb/9sv0pm4x7v1c9ng44rpbqs7r0000gn/T/readme2tex-k3308sx3/6cfc9fee460f304e0df2af7fcf3336f8
Traceback (most recent call last):
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/site-packages/readme2tex/__main__.py", line 160, in <module>
args.bustcache)
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/site-packages/readme2tex/render.py", line 167, in render
svg, dvi, name = rendertex(engine, equation, packages, temp_dir, block)
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/site-packages/readme2tex/render.py", line 44, in rendertex
['dvisvgm', '-v0', '-a', '-n', '-s', dvi])
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/subprocess.py", line 316, in check_output
**kwargs).stdout
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/subprocess.py", line 383, in run
with Popen(*popenargs, **kwargs) as process:
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/Users/bmy4415/.pyenv/versions/3.5.4/lib/python3.5/subprocess.py", line 1289, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'dvisvgm'
I think there are some faults in my LATEX code but not sure.
Can anybody help me?
Hi there,
I want to use readme2tex to compile latex equations for a wiki project where there are multiples Markdown files.
How can I use the git hook command to work over the multiple files?
Best regards
Hi, I'd like to use this program with LuaLaTeX, which provides the graphdrawing
package. Is this possible?
When running python -m readme2tex --output foo.md Summary.md
I encounter this error message: UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 1: ordinal not in range(128)
I get that I must have an unusual char in my document, but how do I get around this?
I don't know why but my math repo was working and I was making ready for my student and teachers in university but that day none of svgs worked
After that I found that rawgit is ended,
Can you see it, maybe I'm wrong ?!!
If it's true can you change the URL for rawgit
Thanks
I change the source code for myself and it's worked
How ever maybe I'm wrong about this.
Thanks for this handy tools
Hail Mathematics for ever
I noticed a bug dealing with new lines in LaTeX blocks.
For example, if my markdown file looks like
the output svg has all of this code in one line.
However, when I insert a new line inside of a matrix, this issue is not present. For example,
works as it should.
I got the error:
File "./readme2tex/render.py", line 180, in render
gfill.set('fill-opacity', '0.9')
AttributeError: 'NoneType' object has no attribute 'set'
For whatever reason my environment's rendertex()
was returning svgs with "http" instead of "https". A quick fix was to change the gfill
and use
variables in render.py
to find the correct string.
gfill = xml.find('{http://www.w3.org/2000/svg}g')
gfill.set('fill-opacity', '0.9')
if not block:
uses = gfill.findall('{http://www.w3.org/2000/svg}use')
If someone knows why my environment did that please let me know. It might also be nice to add some kind of check in the code to prevent the end user from having to alter this.
I found that the inline code and code block which are proceeded by tab
wouldn't be translated by readme2tex.
For instances:
$A^2 + B^2 = C^2$
$$
A^2 + B^2 = C^2
$$
The output translated from the above LaTeX expressions is still the same.
Thanks for your consideration!
Hi, I'd like to use tikz libraries, like \usetikzlibrary{positioning}
. Is this possible? Thank you for your cool project!
In my repo: https://github.com/wlad-svennik/memoized_coduals, all the formulas are showing missing images. If you click on them, you get the error 503: invalid upstream response
. Thanks.
Hi!
Have some problems with inline equation like this
or
Maybe I'm not using correctly your lib.
https://github.com/ViktorRoy94/deep_learning/tree/dev_vroy/lab1
Trying to generate PNGs with this tool, but it seems to not be recognizing the flag. I tried on bleeding edge as well:
python -m readme2tex --output ~/temp/README.md --branch master --nocdn --pngtrick --htmlize --username jjshammas --project test --usepackage tikz README.tex
usage: python -m readme2tex [-h] [--readme [README]] [--engine ENGINE]
[--output OUTPUT] [--usepackage USEPACKAGE]
[--svgdir SVGDIR] [--branch BRANCH]
[--username USERNAME] [--project PROJECT]
[--nocdn] [--htmlize] [--valign] [--rerender]
[--bustcache] [--add-git-hook]
[input]
python -m readme2tex: error: unrecognized arguments: --pngtrick
I couldn't get readme2tex
to generate any images from a markdown file containing a list, formatted like this:
1. First line of the list,
manually broken and continued on this line
along with an equation $Ax=b$
This (perhaps odd...) formatting is due to the text editor I use manually breaking lines rather than wrapping them.
In particular, extract_equations
was returning an empty list when given my file's contents as input. This seemed like it was due to these three lines (lines 69-71) in render.py/extract_equations
.
Indeed, I commented these lines out and everything worked great. What is the intended purpose of these lines? Am I breaking another functionality by commenting them out?
Hi,
I have just installed the package I have tried with the following command
python -m readme2tex --output README.md readme.md
and I have the following error message
Traceback (most recent call last):
File "C:\Users\SESA476345\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\SESA476345\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\users\sesa476345\documents\to_install_latex\readme2tex\readme2tex\__main__.py", line 162, in <module>
args.bustcache)
File "c:\users\sesa476345\documents\to_install_latex\readme2tex\readme2tex\render.py", line 177, in render
xml = (ET.fromstring(svg))
File "C:\Users\SESA476345\AppData\Local\Continuum\anaconda3\lib\xml\etree\ElementTree.py", line 1315, in XML
return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
I am not sure to understand exactly where the problem comes from
First of all, thanks for creating readme2tex -- very cool and useful idea!
I tried to use it in one of my private repos, and, unfortunately, it doesn't seem to work because rawgit doesn't allow to access files in private repos (see #92). At the same time, github doesn't allow accessing SVGs using relative paths for security reasons (see #316).
I am wondering if there is a known workaround for this issue? A straightforward one would be to enable rendering latex as PNGs (optionally) and use relative paths for them. Would it be possible to add support for this?
Hi, I hope that I used everything correctly.
But after successfully running python -m readme2tex --output README.md INPUT.md
I get my README.md file with
<p align="center"><img src="https://rawgit.com/patrick-rode/sudoku/None/svgs/32737e0a8d5a4cf32ba3ab1b74902ab7.svg?invert_in_darkmode" align=middle width=127.9847844pt height=39.452455349999994pt/></p>
in it. Looks good at first, but the URL does not work:
403 Forbidden
RawGit will soon shut down and is no longer serving new repos. Please visit https://rawgit.com/ for more details.
Looks like the recording doesn't work anymore -- page says it has been archived
The README states "this equation dy/dx is preprocessed"... However, there's no equality there! It's just an expression ๐ธ
The following works as expected:
# README
$\phi^2 \ge 0, \forall \in R$
Mathjax and other tex compilers will allow unicode input (probably by including \usepackage[utf8x]{inputenc}
). If I use readme2tex
directly this will not work
# README
$ฯยฒ โฅ 0, โ ฯ โ R$
and instead quietly outputs 0,R
for the math part.
Is it possible to achieve this? If not, I'd like to request unicode support as a feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.