나는 비슷한 일을했습니다 . 프랑스어로되어 있지만 코드 자체를 말해야합니다. 내가 사용하는 ‰
마커 (내가 사용에 대한 bepo의 레이아웃을), 그리고 내가 할 때, 눌러 진 버튼 스타일로 표시된 텍스트입니다.
나는 lisp에 유창하지 않기 때문에 개선의 여지가있을 수 있습니다.
내가 한 것은 ‰
마커에 사용할 때 표시된 텍스트에 버튼 스타일이 있으며 내 보내면 텍스트가<kbd>
먼저 새 얼굴을 정의해야했습니다.
(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)
그런 다음 사용자 정의하십시오 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
수출의 경우,로드해야 할 수 있습니다 ox.el
로 (require 'ox)
.
그런 다음 매번 bold
또는 code
함수 ()에 나타날 ox-org.el
때 비슷한 함수를 만들거나 기존 함수를 수정했습니다.
;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))))))
다음으로 my-html
내보내기에 대한 백엔드를 정의했습니다 .
(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))
따라서 사용 C-c C-e h r
하면 올바르게 내보내집니다.
의견에서 OP가 제안한 것처럼 버퍼 를 사용 org-mode-restart
(또는 org-reload
)하거나 킬 / 다시로드 해야 할 수도 있습니다 .
편집 : 8.3 이전 버전 (8.10.10까지)의 org-mode에서 작동합니다.
≥8.3.1 버전에서는 수정해야합니다
- org-element-all-objects
- 아마도 org-element-object-restrictions
- org-element--set-regexps
- org-element--object-lex
물론 여전히 기능을 추가하십시오
- org-element-my-object-keystroke 파서
- org-element-my-object-keystroke-interpreter
그러나
- org-element-object-successor-alist
- org-element-text-markup-successor
이제 삭제되었습니다.
도움을 주신 Charles C. Berry 에게 감사합니다 .