All Projects → mypebble → rest-framework-latex

mypebble / rest-framework-latex

Licence: MIT license
A LaTeX renderer for Django REST Framework

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to rest-framework-latex

CloudCV
☁️ CloudCV Website
Stars: ✭ 53 (+76.67%)
Mutual labels:  django-rest-framework
django-rest-framework-datatables-editor
Seamless integration between Django REST framework, Datatables and Datatables Editor.
Stars: ✭ 25 (-16.67%)
Mutual labels:  django-rest-framework
dr scaffold
scaffold django rest apis like a champion 🚀
Stars: ✭ 116 (+286.67%)
Mutual labels:  django-rest-framework
filtermapbackend
FilterMapBackend for django-rest-framework
Stars: ✭ 16 (-46.67%)
Mutual labels:  django-rest-framework
drf ujson2
JSON parser and renderer using ujson for Django Rest Framework
Stars: ✭ 29 (-3.33%)
Mutual labels:  django-rest-framework
school-navigator
Navigate the Durham, NC public school system
Stars: ✭ 25 (-16.67%)
Mutual labels:  django-rest-framework
django-learning-pathway
(Currently in development) Learning pathways for learning Django.
Stars: ✭ 35 (+16.67%)
Mutual labels:  django-rest-framework
django-firebase-auth
Django DRF authentication provider for Google's Firebase Authentication Service
Stars: ✭ 50 (+66.67%)
Mutual labels:  django-rest-framework
ai web RISKOUT BTS
국방 리스크 관리 플랫폼 (🏅 국방부장관상/Minister of National Defense Award)
Stars: ✭ 18 (-40%)
Mutual labels:  django-rest-framework
drf tweaks
Extensions for Django Rest Framework
Stars: ✭ 77 (+156.67%)
Mutual labels:  django-rest-framework
Auto-DL
Auto-DL helps you make Deep Learning models without writing a single line of code and giving as little input as possible.
Stars: ✭ 165 (+450%)
Mutual labels:  django-rest-framework
csf
ArmourBird CSF - Container Security Framework
Stars: ✭ 48 (+60%)
Mutual labels:  django-rest-framework
django-rest-framework-example
REST framework example for Django < 1.9 // New version ->
Stars: ✭ 29 (-3.33%)
Mutual labels:  django-rest-framework
DjangoUnboxed
Production ready django based starter kit
Stars: ✭ 67 (+123.33%)
Mutual labels:  django-rest-framework
drf-turbo
An alternative serializer implementation for REST framework written in cython built for speed.
Stars: ✭ 73 (+143.33%)
Mutual labels:  django-rest-framework
Malicious-Urlv5
A multi-layered and multi-tiered Machine Learning security solution, it supports always on detection system, Django REST framework used, equipped with a web-browser extension that uses a REST API call.
Stars: ✭ 35 (+16.67%)
Mutual labels:  django-rest-framework
python-web-dev-21-2
Material for "Web Development in Python with Django" using Django 2.1, published as a Pearson LiveLesson on Safari Books Online
Stars: ✭ 38 (+26.67%)
Mutual labels:  django-rest-framework
django-final
source code for django-final course
Stars: ✭ 28 (-6.67%)
Mutual labels:  django-rest-framework
open
The most boring open source you've ever seen ....
Stars: ✭ 109 (+263.33%)
Mutual labels:  django-rest-framework
repanier
Django extension : web tool for short circuit food supply
Stars: ✭ 18 (-40%)
Mutual labels:  django-rest-framework

REST Framework LaTeX Plugin

CircleCI PyPI version Documentation Status

A simple plug-n-play LaTeX renderer for Django REST Framework.

Documentation

Installing

REST Framework LaTeX can be downloaded from PyPI:

pip install rest-framework-latex

Dependencies

Currently the LaTeX plugin requires lualatex - to install this on Ubuntu:

sudo aptitude install texlive-latex-extra texlive-xetex

This will probably take some time due to the size of LaTeX (around 1GB)

Using the Renderer

You can then configure the renderer in your settings or on each view:

REST_FRAMEWORK = {
  'DEFAULT_RENDERER_CLASSES': [
    'rest_framework_latex.renderers.LatexRenderer',
  ]
}

LATEX_RESOURCES Setting

The LATEX_RESOURCES directory contains the base template environment e.g. any images or static resources to include in your template. This must be set for the renderer to work:

LATEX_RESOURCES = '/home/user/path_to_resources'

This works just like TemplateHTMLRenderer but by setting a latex_name on your view:

from rest_framework import viewsets

from rest_framework_latex import renderers


class SomeViewSet(viewsets.ViewSet):
  """
  """
  renderer_classes = [
    renderers.LatexRenderer,
  ]

  latex_name = 'directory/latexfile.tex'

Latex Templates

To use the template tags, add rest_framework_latex to your INSTALLED_APPS:

INSTALLED_APPS = [
  ...
  'rest_framework_latex',
  ...
]

The TeX file used for rendering will be pushed through Django's templating system. This will cause some issues whereby you want to do something like:

\textt{{{ some_variable }}}

To get around this issue you will need to do something like the following:

\textt{% templatetag openbrace %}{{ some_variable }}{% templatetag closebrace %}

Included Tags

Tag Tag/Filter Purpose
latex_safe Filter Escape all user-entered content for LaTeX rules
latex_resources Tag Print the value of settings.LATEX_RESOURCES

How it works

The renderer works by creating a new temporary directory, and then copying over the LATEX_RESOURCES directory into the new temporary directory.

Next it renders the TeX file into the temporary directory.

Then it runs lualatex over the TeX file, and this will produce the PDF file we read into memory.

Then we delete the temporary directory and return the PDF to the client.

Django Compatibility

The REST Framework LaTeX plugin is compatible with Django 1.11 and up and Django REST Framework 3.3 and up.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].