Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created September 17, 2015 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pr00thmatic/ea3a6b56b8483635bf47 to your computer and use it in GitHub Desktop.
Save pr00thmatic/ea3a6b56b8483635bf47 to your computer and use it in GitHub Desktop.
si por alguna extraña razón quieres copiar cosas de un pdf a un .tex, esto es para tí!
(defun purge-pdf ()
(interactive)
(progn
(goto-char 1)
;; párrafos a salto auxiliar
(while (search-forward-regexp "\\([.\)]\\)\\($\\)\\([^\-]\\)" nil t)
(goto-char (match-end 0))
(insert "ZOMGZALIENZ"))
;; saltos dentro del párrafo
(goto-char 1)
(while (search-forward-regexp "\\($\\)\\([^$]\\)" nil t)
(replace-match " "))
;; salto auxiliar a doble salto
(goto-char 1)
(while (search-forward "ZOMGZALIENZ" nil t) (replace-match "\n\n"))
;; vocales y eñes
(goto-char 1)
(while (search-forward-regexp " ́\\(\s\\)?a" nil t) (replace-match "á"))
(goto-char 1)
(while (search-forward-regexp " ́\\(\s\\)?e" nil t) (replace-match "é"))
(goto-char 1)
(while (search-forward-regexp " ́\\(\s\\)?ı" nil t) (replace-match "í"))
(goto-char 1)
(while (search-forward-regexp " ́\\(\s\\)?o" nil t) (replace-match "ó"))
(goto-char 1)
(while (search-forward-regexp " ́\\(\s\\)?u" nil t) (replace-match "ú"))
(goto-char 1)
(while (search-forward-regexp " ̃\\(\s\\)?n" nil t) (replace-match "ñ"))
;; comillas feas, a comillas latex
(goto-char 1)
(while (search-forward "“" nil t) (replace-match "``"))
(goto-char 1)
(while (search-forward "”" nil t) (replace-match "''"))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment