-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added python file to generate js bibliography variable. Updated READM…
…E. Some formatting changes
- Loading branch information
1 parent
eba1fcd
commit 7660ba1
Showing
3 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,32 @@ This exact reference used in custom_bibliography.js can be found [here](./exampl | |
|
||
This requires the [bibtex-parser](https://github.com/mikolalysenko/bibtex-parser) package also. | ||
|
||
First, download the dependencies and package to the ~/.jupyter/custom location | ||
```bash | ||
mkdir ~/.jupyter/custom | ||
cd ~/.jupyter/custom | ||
git clone [email protected]:mikolalysenko/bibtex-parser.git | ||
git clone [email protected]:michaelplews/jupyter-markdown-citations.git | ||
touch ./jupyter-markdown-citations/custom_bibliography.js | ||
echo 'var bibliography = ""' >> ./jupyter-markdown-citations/custom_bibliography.js | ||
git clone [email protected]:michaelplews/jupyter_markdown_citations.git | ||
cd jupyter_markdown_citations | ||
``` | ||
|
||
- Creates the custom jupyter installs directory | ||
- Installs dependencies | ||
- Installs this package | ||
- Creates the custom_bibliography.js file | ||
- Adds the bibliography variable to the file | ||
Next, symlink (or copy) your .bib file (mine is exported from [Mendeley](https://www.mendeley.com)) to the same folder: | ||
```bash | ||
ln -s /directory/to/bib_file.bib #for symlinking | ||
cp /directory/to/bib_file.bib . #for copying | ||
#only use one of the above options | ||
``` | ||
|
||
Generate the custom_bibliography.js file with the make_bib_js.py file: | ||
```bash | ||
python make_bib_js.py bib_file.bib | ||
``` | ||
Lastly, add this app to your custom.js file: | ||
```bash | ||
cd ~/.jupyter/custom | ||
echo "require(['custom/jupyter_markdown_citations/citations']);" >> custom.js | ||
``` | ||
|
||
Reloading your .iPyNb page in the browser should now load this package. | ||
|
||
This repo is currently under development | ||
Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#Generates the custom_bibliography.js file from a .bib file supplied as an argument | ||
import sys | ||
|
||
def generate_bib_js(bib_file): | ||
file_bib = open(bib_file, 'r') | ||
file_js = open("custom_bibliography.js", "w") | ||
file_js.write("var bibliography = `") | ||
for line in file_bib: | ||
file_js.write(line.replace("`","")) | ||
file_js.write("`") | ||
file_js.close() | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) == 2: | ||
generate_bib_js(sys.argv[1]) | ||
else: | ||
raise ValueError('Only one argument is allowed.') |