Skip to content

Commit

Permalink
Support Org center block
Browse files Browse the repository at this point in the history
Fixes #148.
  • Loading branch information
kaushalmodi committed Mar 19, 2018
1 parent 480aa31 commit edf9c71
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ox-blackfriday.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ Note that this variable is *only* for internal use.")
;; (lambda (a s v b)
;; (if a (org-blackfriday-export-to-markdown t s v)
;; (org-open-file (org-blackfriday-export-to-markdown nil s v)))))))
:translate-alist '((example-block . org-blackfriday-example-block)
:translate-alist '((center-block . org-blackfriday-center-block)
(example-block . org-blackfriday-example-block)
(fixed-width . org-blackfriday-fixed-width) ;Org Babel Results
(footnote-reference . org-blackfriday-footnote-reference)
(inner-template . org-blackfriday-inner-template)
Expand Down Expand Up @@ -387,6 +388,14 @@ style tag."

;;; Transcode Functions

;;;; Center Block
(defun org-blackfriday-center-block (_center-block contents _info)
"Center-align the text in CONTENTS using CSS."
(let* ((class "org-center")
(style (format ".%s { margin-left: auto; margin-right: auto; text-align: center; }" class)))
(format "<style>%s</style>\n\n<div class=\"%s\">\n <div></div>\n\n%s\n</div>" ;See footnote 1
style class contents)))

;;;; Example Block
(defun org-blackfriday-example-block (example-block _contents info)
"Transcode an EXAMPLE-BLOCK element into Blackfriday Markdown format.
Expand Down
30 changes: 29 additions & 1 deletion test/site/content-org/all-posts.org
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,8 @@ Hash char at beginning of a continued line
Markdown]

This ! does not need to be escaped as there is no ambiguity.
** Force line break :force:line_break:
** Force line break / Center align :force:line_break:
*** Force line break
:PROPERTIES:
:EXPORT_FILE_NAME: force-line-break
:END:
Expand All @@ -1950,6 +1951,33 @@ enforce a line break within a paragraph, use ‘\\’ at the end of a line.

Line 1 \\
Line 2
*** Center align :center_align:
:PROPERTIES:
:EXPORT_FILE_NAME: center-align
:END:
From [[https://orgmode.org/manual/Paragraphs.html][=C-h i g (org) Paragraphs=]]:

#+begin_quote
If you would like to center some text, do it like this:

#+begin_src org
,#+begin_center
Everything should be made as simple as possible, \\
but not any simpler
,#+end_center
#+end_src
#+end_quote

#+begin_center
Everything should be made as simple as possible, \\
but not any simpler
#+end_center
**** Testing emphasis in Org center block
#+begin_center
*bold* \\
/italics/ \\
+strikethrough+
#+end_center
* Page Bundles :page_bundles:
:PROPERTIES:
:EXPORT_HUGO_SECTION: bundles
Expand Down
40 changes: 40 additions & 0 deletions test/site/content/posts/center-align.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
+++
title = "Center align"
tags = ["body", "force", "line-break", "center-align"]
draft = false
+++

From [`C-h i g (org) Paragraphs`](https://orgmode.org/manual/Paragraphs.html):

> If you would like to center some text, do it like this:
>
> ```org
> #+begin_center
> Everything should be made as simple as possible, \\
> but not any simpler
> #+end_center
> ```
<style>.org-center { margin-left: auto; margin-right: auto; text-align: center; }</style>
<div class="org-center">
<div></div>
Everything should be made as simple as possible, <br />
but not any simpler
</div>
## Testing emphasis in Org center block {#testing-emphasis-in-org-center-block}
<style>.org-center { margin-left: auto; margin-right: auto; text-align: center; }</style>
<div class="org-center">
<div></div>
**bold** <br />
_italics_ <br />
~~strikethrough~~
</div>

0 comments on commit edf9c71

Please sign in to comment.