Git Product home page Git Product logo

readme2tex's People

Contributors

fulldecent avatar l-winston avatar leegao avatar maxwellgerber avatar philschatz avatar sergeio avatar tapplencourt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

readme2tex's Issues

align=middle does not work on github.io

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.

Difference rawgit.com or raw.githubusercontent.com

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?

Have to remove ?invert_in_darkmode to render images

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.

Remotes that are ssh instead of http

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

Support different (pandoc) markdown syntaxes

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.

Exception for latex in code snippets

works great, but it also renders latex within code snippets that should ideally be left alone:

Here's an example

image

Any way to ignore text within ... regions?

broken/weird URL for 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!

Error executing subprocess.CalledProcessError dvisvgm

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}

Possible to run without being in a git repo?

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.

Support for persistent newcommand definitions

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.

Traceback when using --add-git-hook

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

No such file or directory: 'dvisvgm'

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?

Dark theme issues

I recognize this is a challenging problem to resolve but rendered formulas are invisible in dark mode:

image

How can use readme2tex over multiple files?

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

UnicodeDecodeError

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?

Rawgit URL not work anymore

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

'$' in code blocks

When I write '$' in code block, the script can not work as normal. For example,

$ git clone https://github.com/leegao/readme2tex.git
$ cd readme2tex/

and the script will detect the command as inline equation.

image1

image2

New line in math block

I noticed a bug dealing with new lines in LaTeX blocks.

For example, if my markdown file looks like

$$ x = 1 \\ y = 1, $$

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,

$$ y = \begin{bmatrix} y_1\\ y_2\\ ...\\ y_k \end{bmatrix} $$

works as it should.

gfill is NoneType

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.

[Possible bug report] - Proceeding tab

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.

  • Relative info:
    Package version: 0.0.1b2
    Python version: Python 2.7.17 / Python 3.6.9
    Platform: x86_64 GNU/Linux

Thanks for your consideration!

Using tikz libraries

Hi, I'd like to use tikz libraries, like \usetikzlibrary{positioning}. Is this possible? Thank you for your cool project!

"pngtrick" unrecognized

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

Parsing equations in a markdown list

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?

Failure while compiling

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

Inline equations will insert newlines

I'm not sure if I misconfigured something, but some short inline equations will insert a new line before and after the equation.

Example:
image
instead of
image

And
image
instead of
image

Using readme2tex in private repos

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?

403 Forbidden...?

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.

Support for unicode

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.