Giter Site home page Giter Site logo

wbthomason / pdf-scribe.nvim Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 1.0 57 KB

Neovim plugin for importing annotations and metadata from PDFs

License: MIT License

Lua 60.83% Vim Script 39.17%
neovim neovim-plugin pdf annotations pdf-scribe pdf-files luajit nvim poppler notes

pdf-scribe.nvim's Introduction

pdf-scribe.nvim

A Neovim plugin for importing annotations and metadata from PDFs

Dependencies

You will need LuaJIT (if you're using this with Neovim, it's baked in), poppler-glib, GObject, and GLib installed on your machine.

If you're using Neovim, it needs to be v0.4.3+ (I think - might need to be later).

Installation

Once you have the dependencies installed, use your preferred Neovim package manager. With vim-packager, this looks like:

call packager#add('wbthomason/pdf-scribe.nvim')

Usage

pdf-scribe is (a) a (mostly) Neovim-agnostic LuaJIT library for extracting information (title, author, keywords, external links) and (highlight, underline, and pop-up) annotations from PDFs, and (b) a Neovim plugin serving as an example use of the library/a hopefully good out-of-the-box experience for general users.

For (a), the best documentation is the code. The short version is that the module pdfscribe provides a function load_pdf(pdf_file_path) which returns a PDF object for a given PDF file path. The PDF object has methods to extract the aforementioned information and annotations from its PDF file. There are also convenience functions provided by the pdfscribe module to get just annotations from a PDF (get_annotations(pdf_file_path)) and to get all info from a file (get_all_info(pdf_file_path)).

You can use the pdfscribe library to write your own PDF manipulation plugins.

(b) is designed to cover the most common imagined use case for pdfscribe: creating and updating plain-text notes on PDF files. See the docs for complete information. The short version is that there are two commands provided: :PdfScribeInit to create a notes file and :PdfScribeUpdateNotes to re-extract annotations and update the file. Both commands use configurable templates with primitive conditional value substitution to generate files in whatever format you prefer.

Example Configuration

The only values you must configure are g:pdfscribe_pdf_dir and g:pdfscribe_notes_dir, which set the directory in which pdfscribe looks for your PDF files and for your notes files, respectively. See the docs for more complete information.

Contributing

PRs and issues (bugs and feature requests) are welcome!

Notes

  • The core PDF library only depends on Neovim for checking if files exist. The rest of it is portably reusable in any LuaJIT environment.
  • As the LuaJIT module is a wrapper around a C library, bugs may cause segfaults. Bug reports for segfault bugs are particularly welcomed.
  • This plugin may eat your files, lunch, and/or car.

Known issues

  • Poppler doesn't always agree with the highlight rectangles created by other PDF engines; this can lead to slightly off text selection extraction
  • Highlights including mathematical symbols/other non-ASCII Unicode usually work, but sometimes get chopped up weirdly due to how Poppler determines glyph inclusion in selection regions/maps symbols to UTF-8 codepoints.

TODO

Help is welcome with any of the below! Otherwise, I'll get to them as I have time

  • Reimplement template engine in Lua, make easier to use
  • Reimplement note initialization/update in Lua
  • Refactor pdfscribe module to separate interface and implementation
  • Allow easier customization of note sorting
  • Allow easier customization of note grouping
  • Allow multiple PDF directories/search paths
  • Allow multiple note directories/search paths
  • Add support for ink annotations
  • Add more formatting options: line wrapping, indent matching, etc.

pdf-scribe.nvim's People

Contributors

wbthomason 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

Watchers

 avatar  avatar  avatar  avatar

Forkers

teto

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.