2012-08-13 5 views
5

SFONDOIn Emacs, Come esportare collegamenti ad un link cliccabile, quando htmlize emacs buffer?

  1. I con grande htmlize.el per esportare i miei org-mode contenuto del buffer con font hi-lock.
  2. Emacs org-mode ha un Link format.

PROBLEMA

Per Esempio, ecco un file in modalità org con contenuto:

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

Quando utilizzo Htmlize.el per htmlizzare il buffer in contenuto HTML, il collegamento mancava. produce HTML come:

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

ATTESO

mi aspettavo che produce link cliccabile come:

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

DOMANDA

EDIT1 L'org-export-as -html può esportare t link, ma non può creare CSS per gli Hi-Lock.

  • Conoscete altri modi per esportare i collegamenti in modalità org all'HTML?
  • Per leggere il collegamento reale nel buffer org-mode utilizzando elisp, come fare? leggi il testo proprietà?

GRAZIE IN ANTICIPO, IL TUO AIUTO SARÀ ALTAMENTE APPREZZATO.

+0

** ** CLUE1 Trovo il codice, in che modo org-mode mostra il link in OVERVIEW. '(defun org-columns-compact-links (s) " Sostituisci [[link] [desc]] con [desc] o [link]." (while (string-match org-bracket-link-regexp s) (setq s (replace-match \t (concat" ["(stringa di confronto (if (match-end 3) 3 1) s)" ] ") \t TTS))) s)' ** ESSERE CONTINUA ** – whunmr

risposta

1

Grazie per i suggerimenti 's @Andreas, aggiungo seguente codice per htmlize.el. Attualmente l'org-link può essere htmlized al link cliccabile.

Il codice è stato condiviso su GitHub:

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

e

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

seguito è riportato il codice principale:

(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 dovrebbe dtrt

+0

Ciao @Andreas, grazie per il vostro aiuto. il motivo principale che uso il htmlize.el è quello di mantenere i modelli Hi-lock evidenziato, dopo l'esportazione. Attualmente org-export-as-html non riesce a conservare i font highlight, quindi forse dovremmo aggiungere la funzione di esportazione dei collegamenti a htmlize.el. – whunmr

+0

Grazie mille, forse posso trovare alcuni indizi importanti da codice di org-export-come-html. – whunmr