[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/doc-toc 719f6a03a7 64/84: Return page text when pdfxmet
From: |
ELPA Syncer |
Subject: |
[elpa] externals/doc-toc 719f6a03a7 64/84: Return page text when pdfxmeta fails |
Date: |
Mon, 26 Sep 2022 13:58:39 -0400 (EDT) |
branch: externals/doc-toc
commit 719f6a03a7a7f34a8c7a57bd89f1211cb87b31f8
Author: Daniel Nicolai <dalanicolai@gmail.com>
Commit: Daniel Nicolai <dalanicolai@gmail.com>
Return page text when pdfxmeta fails
---
README.org | 3 ++-
toc-mode.el | 33 ++++++++++++++++++++++++++-------
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index a80e0ad9a0..e343f59dbd 100644
--- a/README.org
+++ b/README.org
@@ -166,10 +166,11 @@ all-modes (i.e. all steps)
| ~C-c C-c~ | dispatch (next step) |
toc-cleanup-mode
| ~C-c C-j~ | toc-join-next-unnumbered-lines |
+| =C-c C-s= | toc--roman-to-arabic |
toc-mode (tablist)
| ~TAB~ | preview/jump-to-page
|
| ~right/left~ | toc-in/decrease-remaining
|
-| ~C-right/C-left~ | toc-in/decrease-remaining and view page
|
+| ~C-right/C-left~ | toc-in/decrease-remaining and view page
|
| ~S-right/S-left~ | in/decrease pagenumber current entry
|
| ~C-down/C-up~ | scroll document other window (only when other buffer
shows document) |
| ~S-down/S-up~ | full page scroll document other window ( idem )
|
diff --git a/toc-mode.el b/toc-mode.el
index 1f339623f3..bf8cfa3c4c 100644
--- a/toc-mode.el
+++ b/toc-mode.el
@@ -36,8 +36,8 @@
;; respectively.
;; Requirements: To use the pdf.tocgen functionality that software has to be
-;; installed (see URL `https://krasjet.com/voice/pdf.tocgen/'). For the other
-;; remaining functionality the package requires the `pdftotext' (part of
+;; installed (see URL `https://krasjet.com/voice/pdf.tocgen/'). For the
+;; remaining functions the package requires the `pdftotext' (part of
;; poppler-utils), `pdfoutline' (part of fntsample) and `djvused' (part of
;; http://djvu.sourceforge.net/) command line utilities to be available.
;; Extraction with OCR requires the tesseract command line utility to be
@@ -262,11 +262,30 @@ document's directory. You will be prompted to enter the
LEVEL
number. The highest level should have number 1, the next leve
number 2 etc."
(interactive "nWhich level you are setting (number): ")
- (shell-command (format "pdfxmeta --auto %s --page %s '%s' \"%s\" >>
recipe.toml"
- level
- (pdf-view-current-page)
- (url-filename (url-generic-parse-url
buffer-file-name))
- (car (pdf-view-active-region-text)))))
+ (let* ((page (pdf-view-current-page))
+ (filename (url-filename (url-generic-parse-url buffer-file-name)))
+ (pdfxmeta-result (shell-command
+ (format "pdfxmeta --auto %s --page %s '%s' \"%s\"
>> recipe.toml"
+ level
+ page
+ filename
+ (car (pdf-view-active-region-text))))))
+ (when (eq pdfxmeta-result 1)
+ (let ((page-text (shell-command-to-string
+ (format "mutool draw -F text '%s' %s"
+ filename
+ page
+ ))))
+ (pop-to-buffer "page-text")
+ (insert
+ "COULD NOT SET HEADING LEVEL. MUPDF EXTRACTED FOLLOWING PAGE TEXT
FROM PAGE:\n")
+ (add-text-properties 1 (point) '(face font-lock-warning-face))
+ (let ((beg (point)))
+ (insert "(try to select partial word)\n\n")
+ (add-text-properties beg (point) '(face font-lock-warning-face)))
+ (insert page-text)
+ (beginning-of-buffer)))))
+
(defun toc-extract-with-pdf-tocgen ()
"Extract Table of Contents with `pdf-tocgen'.
- [elpa] externals/doc-toc a1d26eceb5 37/84: Add defvar and declare-function to avoid warning MELPA, (continued)
- [elpa] externals/doc-toc a1d26eceb5 37/84: Add defvar and declare-function to avoid warning MELPA, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 05cd1287f1 42/84: Fix toc--add-to-djvu. Don't ask save location., ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc f430243a88 43/84: Add version: 0 header, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 59f4471e6a 50/84: Update README.org, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 2d95c466a3 48/84: Add MELPA and GPL3 badges, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 734043bdc7 47/84: Improve documentation in toc-mode.el, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc ae455b4863 52/84: Implement language customization for OCR, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 23e1fb2fde 54/84: Implement HandyOutliner option, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc b45b78102c 55/84: Update README, add extract-only documentation, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc b1a843fd6f 57/84: Implement roman-to-arabic and add pdf djvu keybindings, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 719f6a03a7 64/84: Return page text when pdfxmeta fails,
ELPA Syncer <=
- [elpa] externals/doc-toc dd1dfd83ac 63/84: Fix docstrings and warnings for MELPA, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 7e2e6be947 69/84: Update/improve README, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 782d0cd6b5 80/84: Update README.org, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 977bec00d8 74/84: Tiny bug fix in toc--tablist-to-handyoutliner, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 448a0ac00c 82/84: Small fixes before release on ELPA (fix compiler warnings), ELPA Syncer, 2022/09/26