{"id":13765882,"url":"https://github.com/mypebble/rest-framework-latex","last_synced_at":"2025-04-12T12:21:27.790Z","repository":{"id":49708917,"uuid":"59004921","full_name":"mypebble/rest-framework-latex","owner":"mypebble","description":"A LaTeX renderer for Django REST Framework","archived":false,"fork":false,"pushed_at":"2021-06-10T18:02:08.000Z","size":42,"stargazers_count":35,"open_issues_count":5,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T07:03:57.301Z","etag":null,"topics":["django","django-rest-framework","latex","latex-renderer","pdf","rest","rest-framework","tex"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mypebble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-17T08:35:05.000Z","updated_at":"2024-10-22T22:42:25.000Z","dependencies_parsed_at":"2022-09-26T18:11:02.621Z","dependency_job_id":null,"html_url":"https://github.com/mypebble/rest-framework-latex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mypebble%2Frest-framework-latex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mypebble%2Frest-framework-latex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mypebble%2Frest-framework-latex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mypebble%2Frest-framework-latex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mypebble","download_url":"https://codeload.github.com/mypebble/rest-framework-latex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161292,"owners_count":21057556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","latex","latex-renderer","pdf","rest","rest-framework","tex"],"created_at":"2024-08-03T16:00:47.908Z","updated_at":"2025-04-12T12:21:27.770Z","avatar_url":"https://github.com/mypebble.png","language":"Python","funding_links":[],"categories":["Packages","Python"],"sub_categories":["Renderers and Parsers"],"readme":"# REST Framework LaTeX Plugin\n\n[![CircleCI](https://circleci.com/gh/mypebble/rest-framework-latex.svg?style=svg)](https://circleci.com/gh/mypebble/rest-framework-latex)\n[![PyPI version](https://badge.fury.io/py/rest-framework-latex.svg)](https://badge.fury.io/py/rest-framework-latex)\n[![Documentation Status](https://readthedocs.org/projects/drf-latex/badge/?version=latest)](http://drf-latex.readthedocs.io/en/latest/?badge=latest)\n\nA simple plug-n-play LaTeX renderer for Django REST Framework.\n\n[Documentation](http://drf-latex.readthedocs.io/en/latest/)\n\n## Installing\n\nREST Framework LaTeX can be downloaded from PyPI:\n\n```bash\npip install rest-framework-latex\n```\n\n## Dependencies\n\nCurrently the LaTeX plugin requires `lualatex` - to install this on Ubuntu:\n\n```bash\nsudo aptitude install texlive-latex-extra texlive-xetex\n```\n\nThis will probably take some time due to the size of LaTeX (around 1GB)\n\n## Using the Renderer\n\nYou can then configure the renderer in your settings or on each view:\n\n```python\nREST_FRAMEWORK = {\n  'DEFAULT_RENDERER_CLASSES': [\n    'rest_framework_latex.renderers.LatexRenderer',\n  ]\n}\n```\n\n### `LATEX_RESOURCES` Setting\n\nThe `LATEX_RESOURCES` directory contains the base template environment e.g.\nany images or static resources to include in your template. This must be set for\nthe renderer to work:\n\n```python\nLATEX_RESOURCES = '/home/user/path_to_resources'\n```\n\nThis works just like `TemplateHTMLRenderer` but by setting a `latex_name` on\nyour view:\n\n```python\nfrom rest_framework import viewsets\n\nfrom rest_framework_latex import renderers\n\n\nclass SomeViewSet(viewsets.ViewSet):\n  \"\"\"\n  \"\"\"\n  renderer_classes = [\n    renderers.LatexRenderer,\n  ]\n\n  latex_name = 'directory/latexfile.tex'\n```\n\n### Latex Templates\n\nTo use the template tags, add `rest_framework_latex` to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n  ...\n  'rest_framework_latex',\n  ...\n]\n```\n\nThe TeX file used for rendering will be pushed through Django's templating\nsystem. This will cause some issues whereby you want to do something like:\n\n```latex\n\\textt{{{ some_variable }}}\n```\n\nTo get around this issue you will need to do something like the following:\n\n```latex\n\\textt{% templatetag openbrace %}{{ some_variable }}{% templatetag closebrace %}\n```\n\n#### Included Tags\n\n| Tag               | Tag/Filter | Purpose                                         |\n| ----------------- | ---------- | ----------------------------------------------- |\n| `latex_safe`      | Filter     | Escape all user-entered content for LaTeX rules |\n| `latex_resources` | Tag        | Print the value of `settings.LATEX_RESOURCES`   |\n\n## How it works\n\nThe renderer works by creating a new temporary directory, and then copying\nover the `LATEX_RESOURCES` directory into the new temporary directory.\n\nNext it renders the TeX file into the temporary directory.\n\nThen it runs lualatex over the TeX file, and this will produce the PDF file\nwe read into memory.\n\nThen we delete the temporary directory and return the PDF to the client.\n\n## Django Compatibility\n\nThe REST Framework LaTeX plugin is compatible with Django 1.11 and up and\nDjango REST Framework 3.3 and up.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmypebble%2Frest-framework-latex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmypebble%2Frest-framework-latex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmypebble%2Frest-framework-latex/lists"}