Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rawgit URL not work anymore #22

Open
JARVIS-AI opened this issue Oct 17, 2018 · 9 comments
Open

Rawgit URL not work anymore #22

JARVIS-AI opened this issue Oct 17, 2018 · 9 comments

Comments

@JARVIS-AI
Copy link

JARVIS-AI commented Oct 17, 2018

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

@JARVIS-AI
Copy link
Author

JARVIS-AI commented Oct 17, 2018

@JARVIS-AI
Copy link
Author

One question :
Can the readme2tex make the svgs url locally
For e.g :
when I render the file
The url of svg being like this :

If this can be done we don't need any online services and I think it will work on github too

@atreyasha
Copy link

Hello @JARVIS-AI,

Yes, the rawgit service is ending or has ended (https://rawgit.com/), so this creates an issue with the images not being displayed.

As a work around, I edit the links after running readme2tex on my README.md, such that the SVGs are displayed locally on GitHub without the rawgit link.

While waiting for an internal bug fix, I could recommend that we use a pre-commit hook which can edit the links for us. I will test it out and post a version here.

@atreyasha
Copy link

atreyasha commented Oct 27, 2018

Based on my experiments, the following pre-commit hook solves the issue (in an improvised manner). It essentially re-creates the link to the svg files as local files on your github. This is assuming you have a folder named "svgs" on your master branch. It also removes centering, which is a personal preference.

Lastly, it removes svgs in your svgs/ folder that are not being used in your README.md. This ensures only necessary files are present on your repository.

To use this file, essentially copy its contents to a file named "pre-commit" within your local repository's /.git/hooks directory.

Hope this helps!

#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.	The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit". 

b=$(find README.md 2>/dev/null)
c=$(find svgs/ 2>/dev/null)

if [ ${#b} -gt 0 ] && [ ${#c} -gt 0 ]
then
	# to remove centering of images, this is a personal preference
	sed -i "s| align=\"center\"||g" README.md
	# these help to remove the faulty links
	sed -i "s|img src=.*/svgs|img src=\"/svgs|g" README.md
	sed -i "s|\?invert\_in\_darkmode||g" README.md
        # find all used svgs
	svgs=$(cat README.md | grep -oP "/svgs.*.svg" | sed "s|/svgs/||g")
        # find svgs to delete
	del=$(find svgs/*.svg | grep -v "$svgs")

        # if more than 0, delete unused svgs
	if [ ${#del} -gt 0 ]
	then
		rm $del
	fi
        git add .
fi

if git rev-parse --verify HEAD >/dev/null 2>&1
then
	against=HEAD
else
	# Initial commit: diff against an empty tree object
	against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)

# Redirect output to stderr.
exec 1>&2

# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
	# Note that the use of brackets around a tr range is ok here, (it's
	# even required, for portability to Solaris 10's /usr/bin/tr), since
	# the square bracket bytes happen to fall in the designated range.
	test $(git diff --cached --name-only --diff-filter=A -z $against |
	LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
	cat <<\EOF
	Error: Attempt to add a non-ASCII file name.

	This can cause problems if you want to work with people on other platforms.

	To be portable it is advisable to rename the file.

	If you know what you are doing you can disable this check using:

	git config hooks.allownonascii true
EOF
	exit 1
fi

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

@JARVIS-AI
Copy link
Author

Thanks for a temp script or fix thanks
Hope the new version be out with full fix
I will test the shell script and give the result

@tonyduan
Copy link

tonyduan commented Feb 20, 2019

This is still an issue. One workaround is to use the following, with the latest version of this package:

python3 -m readme2tex --branch master --nocdn --readme INPUT.md --output README.md

@WorldSEnder
Copy link

	sed -i "s|img src=.*/svgs|img src=\"/svgs|g" README.md
	sed -i "s|\?invert\_in\_darkmode||g" README.md
        # find all used svgs
	svgs=$(cat README.md | grep -oP "/svgs.*.svg" | sed "s|/svgs/||g")

I found that the following regular expressions worked better, when combined with --nocdn. Fixes a problem when having multiple images on the same line.

	sed -i "s|img src=\"\([^/]\)|img src=\"/\1|g" README.md
	sed -i "s|\?invert\_in\_darkmode||g" README.md
        # find all used svgs
	svgs=$(cat README.md | grep -oP "/svgs.*?.svg" | sed "s|/svgs/||g") 

@JARVIS-AI
Copy link
Author

For ‘’nocdn’’
Yes it worked for times
Needed to be updated for another cdn or self services server for better work any where not just locally or offline

@WorldSEnder
Copy link

Also you probably don't want to do

        git add .

but instead

        git add svgs/ README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants