2012-08-13 16 views
5

AntecedentesEn Emacs, Cómo exportar enlaces a un enlace cliqueable, cuando htmlize emacs buffer?

  1. I utilizando gran htmlize.el exportar mis contenidos del búfer en modo org con la fuente hi-lock.
  2. Emacs org-mode tiene un problema

    Link format.

Para Ejemplo, aquí hay un archivo org-mode con contenido:

[[http://hunmr.blogspot.com][blog]] 

Cuando uso Htmlize.el para htmlize el búfer a los contenidos HTML, Faltaba el enlace. produce HTML como:

<span style="hyperlinkFOOBAR">blog</span> 

ESPERADO

que esperaba que produce enlace activo como:

<a style="hyperlinkFOOBAR" href="http://hunmr.blogspot.com">blog</a> 

PREGUNTA

EDIT1 La org-export-tan -html puede expor t Enlace, pero no puede crear CSS para Hi-Locks.

  • ¿Conoces otras formas de exportar enlaces org-mode a HTML?
  • Para leer el enlace real en el búfer org-mode usando elisp, ¿cómo hacer eso? leer texto propiedad?

GRACIAS DE INMEDIATO, SU AYUDA SERÁ MUY APRECIADA.

+0

** **CLUEEncontré el código, cómo org-mode muestra el enlace en OVERVIEW. '(defun org-columns-compact-links (s) " Reemplazar [[link] [desc]] con [desc] o [link]." (while (string-match org-bracket-link-regexp s) (setq s (replace-match \t (concat" ["(match-string (if (match-end 3) 3 1) s)" ] ") \t TTS))) s)' ** se CONTINUAR ** – whunmr

Respuesta

1

Gracias por consejos @Andreas 's, añado siguiente código para htmlize.el. Actualmente, el enlace de organización se puede htmlizar para hacer clic en el enlace.

El código fue compartido en github:

https://github.com/whunmr/dotemacs/blob/master/site-lisp/htmlize.el

y

http://hunmr.blogspot.com/2012/08/enhance-htmlizeel-now-can-export-org.html

siguiente es el código principal:

(defun expand-org-link (&optional buffer) 
    "Change [[url][shortname]] to [[url] [shortname]] by adding a space between url and shortname" 
    (goto-char (point-min)) 
    (while (re-search-forward "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" 
       nil t) 
    (let ((url (match-string 1)) 
     (link-text (match-string 3))) 
     (delete-region (match-beginning 0) (match-end 0)) 
     (insert "[[" url "] [" link-text "]]")))) 

(defun shrink-org-link (&optional buffer) 
    "Change [[url] [shortname]] to [[url][shortname]], remove the space between url and shortname" 
    (goto-char (point-min)) 
    (while (re-search-forward "\\[\\[\\([^][]+\\)\\] \\(\\[\\([^][]+\\)\\]\\)?\\]" 
       nil t) 
    (let ((url (match-string 1)) 
     (link-text (match-string 3))) 
     (delete-region (match-beginning 0) (match-end 0)) 
     (insert "[[" url "][" link-text "]]")))) 

(defun transform-org-link() 
    "transform htmlized <span> to <a>" 
    (goto-char (point-min)) 
    (while (re-search-forward "\\[\\[<span \\([^>]+\\)>\\([^][]+\\)</span>\\] \\[\\([^][]+\\)\\]\\]" 
       nil t) 
    (let ((style (match-string 1)) 
      (url (match-string 2)) 
     (link-text (match-string 3))) 
     (delete-region (match-beginning 0) (match-end 0)) 
     (insert "<a " style " href=\"" url "\">" link-text "</a>")))) 
1

org-export-as-html debe DTRT

+0

Hola @Andreas, gracias por su ayuda. la razón principal uso el htmlize.el es mantener los patrones de Hi-lock resaltado, después de exportar. Pero org-export-as-html actualmente no puede mantener las fuentes destacadas. Así que creo que tal vez necesitamos agregar la función de exportación de enlaces a htmlize.el. – whunmr

+0

Muchas gracias, tal vez pueda encontrar algunas pistas importantes de código de org-export-as-html. – whunmr

Cuestiones relacionadas