Eu fiz algo semelhante . Está em francês, mas o código deve falar por si. Uso ‰
para o marcador (uso um layout bepo ) e, quando uso, o texto marcado como um estilo de botão pressionado.
Eu não sou fluente em língua estrangeira, então pode haver espaço para melhorias.
O que fiz foi que, ao usar ‰
para marcador, o texto marcado possui um estilo de botão pressionado e, quando exportado, é traduzido para<kbd>
Primeiro, tive que definir um novo rosto:
(defface my-face-org-keystroke
'((t (:inherit shadow
:box (:line-width -2 ;neg. in order to keep the same size of lines
:color "grey75"
:style pressed-button)))) "Face for keystrokes"
:group 'org-faces)
Em seguida, personalize org-emphasis-alist
:
(("*" bold)
("/" italic)
("_" underline)
("=" org-code verbatim)
("~" org-verbatim verbatim)
("+"
(:strike-through t))
("‰" my-face-org-keystroke verbatim));This line is what you want to add
Para a exportação, você pode precisar de carregar ox.el
com (require 'ox)
.
Em seguida, cada vez que bold
ou code
aparece em uma função (em ox-org.el
), eu criei uma função semelhante (ou modificados os já existentes):
;creation
(defun org-html-keystroke (keystroke contents info)
"Transcode KEYSTROKE from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format (or (cdr (assq 'my-object-keystroke org-html-text-markup-alist)) "%s")
(org-html-encode-plain-text (org-element-property :value keystroke))))
;creation
(defun org-element-my-object-keystroke-parser ()
"Parse code object at point.
Return a list whose CAR is `my-object-keystroke' and CDR is a plist with
`:value', `:begin', `:end' and `:post-blank' keywords.
Assume point is at the first tilde marker."
(interactive)
(save-excursion
(unless (bolp) (backward-char 1))
(looking-at org-emph-re)
(let ((begin (match-beginning 2))
(value (org-match-string-no-properties 4))
(post-blank (progn (goto-char (match-end 2))
(skip-chars-forward " \t")))
(end (point)))
(list 'my-object-keystroke
(list :value value
:begin begin
:end end
:post-blank post-blank)))))
;creation
(defun org-element-my-object-keystroke-interpreter (keystroke contents)
"Interpret KEYSTROKE object as Org syntax.
CONTENTS is nil."
(format "‰%s‰" (org-element-property :value keystroke)))
;modification
(defconst org-element-object-successor-alist
'((subscript . sub/superscript) (superscript . sub/superscript)
(bold . text-markup) (code . text-markup) (italic . text-markup)
(strike-through . text-markup) (underline . text-markup)
(verbatim . text-markup) (entity . latex-or-entity)
(latex-fragment . latex-or-entity) (my-object-keystroke . text-markup))
"Alist of translations between object type and successor name.
Sharing the same successor comes handy when, for example, the
regexp matching one object can also match the other object.")
;modification
(defconst org-element-all-objects
'(bold code entity export-snippet footnote-reference inline-babel-call
inline-src-block italic line-break latex-fragment link macro
radio-target statistics-cookie strike-through subscript superscript
table-cell target timestamp underline verbatim my-object-keystroke)
"Complete list of object types.")
;modification
(defun org-element-text-markup-successor ()
"Search for the next text-markup object.
Return value is a cons cell whose CAR is a symbol among `bold',
`italic', `underline', `strike-through', `code' and `verbatim'
and CDR is beginning position."
(save-excursion
(unless (bolp) (backward-char))
(when (re-search-forward org-emph-re nil t)
(let ((marker (match-string 3)))
(cons (cond
((equal marker "*") 'bold)
((equal marker "/") 'italic)
((equal marker "_") 'underline)
((equal marker "+") 'strike-through)
((equal marker "~") 'code)
((equal marker "=") 'verbatim)
((equal marker "‰") 'my-object-keystroke)
(t (error "Unknown marker at %d" (match-beginning 3))))
(match-beginning 2))))))
Em seguida, defini um my-html
back - end para a exportação:
(org-export-define-derived-backend 'my-html 'html
:translate-alist '((my-object-keystroke . org-html-keystroke))
:menu-entry ' (?h 1
((?r "my-html" org-html-export-to-my-html))))
(defun org-html-export-to-my-html
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a HTML file.
Return output file's name."
(interactive)
(let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension subtreep))
(org-export-coding-system org-html-coding-system))
(org-export-to-file 'my-html file
async subtreep visible-only body-only ext-plist)))
(defun org-html-publish-to-my-html (plist filename pub-dir)
"Publish an org file to my-html.
Return output file name."
(org-publish-org-to 'my-html filename
(concat "." (or (plist-get plist :html-extension)
org-html-extension "html"))
plist pub-dir))
(defun org-html-convert-region-to-my-html ()
"Assume the current region has org-mode syntax, and convert it to HTML.
This can be used in any buffer. For example, you can write an
itemized list in org-mode syntax in an HTML buffer and use this
command to convert it."
(interactive)
(org-export-replace-region-by 'my-html))
Então, quando eu uso C-c C-e h r
, é exportado corretamente:
Conforme sugerido pelo OP nos comentários, pode ser necessário usar org-mode-restart
(ou org-reload
) ou matar / recarregar seu buffer.
Edit: Isso funciona para o modo organizacional com versões anteriores à 8.3 (que é até 8.2.10)
Nas versões ≥8.3.1, tenho que modificar
- org-elemento-todos-objetos
- possivelmente restrições de objeto-elemento-org
- elemento-org - conjunto-regexps
- elemento-org - objeto-lex
e, claro, ainda adicionar as funções
- elemento-org-meu-objeto-analisador de teclas
- org-elemento-meu-objeto-teclado-interpretador
mas
- org-elemento-objeto-sucessor-alista
- org-elemento-texto-marcação-sucessor
agora são excluídos.
Obrigado a Charles C. Berry por sua ajuda.