Untabify
This commit is contained in:
parent
1e4cabf98a
commit
7897f8eb84
146
ox-gemini.el
146
ox-gemini.el
@ -39,20 +39,20 @@
|
||||
:menu-entry
|
||||
'(?g "Export to Gemini"
|
||||
((?b "To buffer"
|
||||
(lambda (a s v b)
|
||||
(org-gemini-export-to-buffer a s v b nil)))
|
||||
(?f "To file"
|
||||
(lambda (a s v b)
|
||||
(org-gemini-export-to-file a s v b nil)))))
|
||||
(lambda (a s v b)
|
||||
(org-gemini-export-to-buffer a s v b nil)))
|
||||
(?f "To file"
|
||||
(lambda (a s v b)
|
||||
(org-gemini-export-to-file a s v b nil)))))
|
||||
:translate-alist '((code . org-gemini-code-inline)
|
||||
(paragraph . org-gemini-paragraph)
|
||||
(headline . org-gemini-headline)
|
||||
(link . org-gemini-link)
|
||||
(section . org-gemini-section)
|
||||
(src-block . org-gemini-code-block)
|
||||
(headline . org-gemini-headline)
|
||||
(link . org-gemini-link)
|
||||
(section . org-gemini-section)
|
||||
(src-block . org-gemini-code-block)
|
||||
(item . org-gemini-item)
|
||||
(quote-block . org-gemini-quote-block)
|
||||
(template . org-gemini-template)))
|
||||
(template . org-gemini-template)))
|
||||
|
||||
(defun org-gemini-paragraph (_paragraph contents _info)
|
||||
"CONTENTS is the text of the paragraph."
|
||||
@ -76,7 +76,7 @@
|
||||
"EXAMPLE-BLOCK is a codeblock. INFO is a plist."
|
||||
(org-remove-indentation
|
||||
(format "```\n%s```"
|
||||
(org-export-format-code-default example-block info))))
|
||||
(org-export-format-code-default example-block info))))
|
||||
|
||||
(defun org-gemini--describe-links (links _width info)
|
||||
"Describe links is the footer-portion of the link data.
|
||||
@ -92,10 +92,10 @@ It's output just before each section. LINKS is a list of each link. INFO is a
|
||||
(path (if is-org-file-link
|
||||
(concat (file-name-sans-extension (org-element-property :path link)) ".gmi")
|
||||
raw-path))
|
||||
(desc (org-element-contents link))
|
||||
(anchor (org-export-data
|
||||
(or desc (org-element-property :raw-link link))
|
||||
info)))
|
||||
(desc (org-element-contents link))
|
||||
(anchor (org-export-data
|
||||
(or desc (org-element-property :raw-link link))
|
||||
info)))
|
||||
(format "=> %s %s\n" path anchor)))
|
||||
links "")
|
||||
(when (car links)
|
||||
@ -118,20 +118,20 @@ org-gemini--describe-links"
|
||||
CONTENTS is the contents of the section. INFO is a plist holding
|
||||
contextual information."
|
||||
(let ((links
|
||||
(and (plist-get info :ascii-links-to-notes)
|
||||
;; Take care of links in first section of the document.
|
||||
(not (org-element-lineage section '(headline)))
|
||||
(org-gemini--describe-links
|
||||
(org-ascii--unique-links section info)
|
||||
(org-ascii--current-text-width section info)
|
||||
info))))
|
||||
(and (plist-get info :ascii-links-to-notes)
|
||||
;; Take care of links in first section of the document.
|
||||
(not (org-element-lineage section '(headline)))
|
||||
(org-gemini--describe-links
|
||||
(org-ascii--unique-links section info)
|
||||
(org-ascii--current-text-width section info)
|
||||
info))))
|
||||
(org-remove-indentation
|
||||
(if (not (org-string-nw-p links)) contents
|
||||
(concat (org-element-normalize-string contents) "\n\n" links))
|
||||
(concat (org-element-normalize-string contents) "\n\n" links))
|
||||
;; Do not apply inner margin if parent headline is low level.
|
||||
(let ((headline (org-export-get-parent-headline section)))
|
||||
(if (or (not headline) (org-export-low-level-p headline info)) 0
|
||||
(plist-get info :ascii-inner-margin))))))
|
||||
(if (or (not headline) (org-export-low-level-p headline info)) 0
|
||||
(plist-get info :ascii-inner-margin))))))
|
||||
|
||||
(defun org-gemini--build-title
|
||||
(element info _text-width &optional _underline _notags toc)
|
||||
@ -139,13 +139,13 @@ contextual information."
|
||||
|
||||
ELEMENT is an org-element. TOC is whether to show the table of contents. INFO is unimportant."
|
||||
(let ((number (org-element-property :level element))
|
||||
(text
|
||||
(org-trim
|
||||
(org-export-data
|
||||
(if toc
|
||||
(org-export-get-alt-title element info)
|
||||
(org-element-property :title element))
|
||||
info))))
|
||||
(text
|
||||
(org-trim
|
||||
(org-export-data
|
||||
(if toc
|
||||
(org-export-get-alt-title element info)
|
||||
(org-element-property :title element))
|
||||
info))))
|
||||
|
||||
(format "%s %s" (make-string number ?#) text)))
|
||||
|
||||
@ -158,49 +158,49 @@ holding contextual information."
|
||||
;; of the template.
|
||||
(unless (org-element-property :footnote-section-p headline)
|
||||
(let* ((low-level (org-export-low-level-p headline info))
|
||||
(width (org-ascii--current-text-width headline info))
|
||||
;; Export title early so that any link in it can be
|
||||
;; exported and seen in `org-ascii--unique-links'.
|
||||
(title (org-gemini--build-title headline info width (not low-level)))
|
||||
;; Blank lines between headline and its contents.
|
||||
;; `org-ascii-headline-spacing', when set, overwrites
|
||||
;; original buffer's spacing.
|
||||
(pre-blanks
|
||||
(make-string (or (car (plist-get info :ascii-headline-spacing))
|
||||
(org-element-property :pre-blank headline)
|
||||
0)
|
||||
?\n))
|
||||
(links (and (plist-get info :ascii-links-to-notes)
|
||||
(org-gemini--describe-links
|
||||
(org-ascii--unique-links headline info) width info)))
|
||||
;; Re-build contents, inserting section links at the right
|
||||
;; place. The cost is low since build results are cached.
|
||||
(body
|
||||
(if (not (org-string-nw-p links)) contents
|
||||
(let* ((contents (org-element-contents headline))
|
||||
(section (let ((first (car contents)))
|
||||
(and (eq (org-element-type first) 'section)
|
||||
first))))
|
||||
(concat (and section
|
||||
(concat (org-element-normalize-string
|
||||
(org-export-data section info))
|
||||
"\n\n"))
|
||||
links
|
||||
(mapconcat (lambda (e) (org-export-data e info))
|
||||
(if section (cdr contents) contents)
|
||||
""))))))
|
||||
(width (org-ascii--current-text-width headline info))
|
||||
;; Export title early so that any link in it can be
|
||||
;; exported and seen in `org-ascii--unique-links'.
|
||||
(title (org-gemini--build-title headline info width (not low-level)))
|
||||
;; Blank lines between headline and its contents.
|
||||
;; `org-ascii-headline-spacing', when set, overwrites
|
||||
;; original buffer's spacing.
|
||||
(pre-blanks
|
||||
(make-string (or (car (plist-get info :ascii-headline-spacing))
|
||||
(org-element-property :pre-blank headline)
|
||||
0)
|
||||
?\n))
|
||||
(links (and (plist-get info :ascii-links-to-notes)
|
||||
(org-gemini--describe-links
|
||||
(org-ascii--unique-links headline info) width info)))
|
||||
;; Re-build contents, inserting section links at the right
|
||||
;; place. The cost is low since build results are cached.
|
||||
(body
|
||||
(if (not (org-string-nw-p links)) contents
|
||||
(let* ((contents (org-element-contents headline))
|
||||
(section (let ((first (car contents)))
|
||||
(and (eq (org-element-type first) 'section)
|
||||
first))))
|
||||
(concat (and section
|
||||
(concat (org-element-normalize-string
|
||||
(org-export-data section info))
|
||||
"\n\n"))
|
||||
links
|
||||
(mapconcat (lambda (e) (org-export-data e info))
|
||||
(if section (cdr contents) contents)
|
||||
""))))))
|
||||
;; Deep subtree: export it as a list item.
|
||||
(if low-level
|
||||
(let* ((bullets (cdr (assq (plist-get info :ascii-charset)
|
||||
(plist-get info :ascii-bullets))))
|
||||
(bullet
|
||||
(format "%c "
|
||||
(nth (mod (1- low-level) (length bullets)) bullets))))
|
||||
(concat bullet title "\n" pre-blanks
|
||||
;; Contents, indented by length of bullet.
|
||||
(org-ascii--indent-string body (length bullet))))
|
||||
;; Else: Standard headline.
|
||||
(concat title "\n" pre-blanks body)))))
|
||||
(let* ((bullets (cdr (assq (plist-get info :ascii-charset)
|
||||
(plist-get info :ascii-bullets))))
|
||||
(bullet
|
||||
(format "%c "
|
||||
(nth (mod (1- low-level) (length bullets)) bullets))))
|
||||
(concat bullet title "\n" pre-blanks
|
||||
;; Contents, indented by length of bullet.
|
||||
(org-ascii--indent-string body (length bullet))))
|
||||
;; Else: Standard headline.
|
||||
(concat title "\n" pre-blanks body)))))
|
||||
|
||||
(defun org-gemini-template (contents info)
|
||||
"Return complete document string after GEMINI conversion.
|
||||
|
Loading…
Reference in New Issue
Block a user