Skip to content

Commit

Permalink
Preserve line breaks when exporting from Org to Hugo md
Browse files Browse the repository at this point in the history
That way if auto-filling is enabling in the Org document, the
generated Markdown will have a similar text filling.
  • Loading branch information
kaushalmodi committed Jul 22, 2017
1 parent b130e2b commit 1f62a39
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 34 deletions.
6 changes: 5 additions & 1 deletion example-site/content/articles/article-1.md
Expand Up @@ -7,4 +7,8 @@ draft = false

First article.

This will land in `content/articles/` as the parent of this subtree sets `EXPORT_HUGO_SECTION` to `articles`. Note that the theme needs to define at least the `single.html`, either in the `layouts/_default/` directory, or `layouts/articles/`, either in the Hugo base dir or the theme dir.
This will land in `content/articles/` as the parent of this subtree
sets `EXPORT_HUGO_SECTION` to `articles`. Note that the theme needs to
define at least the `single.html`, either in the `layouts/_default/`
directory, or `layouts/articles/`, either in the Hugo base dir or the
theme dir.
15 changes: 11 additions & 4 deletions example-site/content/posts/code-fenced-src-blocks.md
Expand Up @@ -13,19 +13,26 @@ Here are few variables that you might like to change in the `local.mk`:
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
```
The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by default. If you’d like to change that, you can tweak the `lispdir` variable.
- **`infodir`:** Org Info installation directory. I like to keep the Info file for development version of Org in a separate directory.
The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you’d like to change that, you can tweak the
`lispdir` variable.
- **`infodir`:** Org Info installation directory. I like to keep the
Info file for development version of Org in a separate
directory.
```makefile
infodir = $(prefix)/org/info # Default: $(prefix)/info
```
- **`ORG_MAKE_DOC`:** Types of Org documentation you’d like to build by default.
- **`ORG_MAKE_DOC`:** Types of Org documentation you’d like to build by
default.
```makefile
# Define below you only need info documentation, the default includes html and pdf
ORG_MAKE_DOC = info pdf card # html
```
- **`ORG_ADD_CONTRIB`:** Packages from the `contrib/` directory that you’d like to build along with Org. Below are the ones on my *must-have* list.
- **`ORG_ADD_CONTRIB`:** Packages from the `contrib/` directory that
you’d like to build along with Org. Below are the ones on my
*must-have* list.
```makefile
# Define if you want to include some (or all) files from contrib/lisp
Expand Down
9 changes: 6 additions & 3 deletions example-site/content/posts/dealing-with-underscores.md
Expand Up @@ -7,8 +7,11 @@ draft = false

This underscore should appear escaped in Markdown: \_

This underscore is in a verbatim block, so it should not be escaped: `_`
This underscore is in a verbatim block, so it should not be escaped:
`_`

This underscore also shouldn’t be escaped as it’s in an emoji code: :raised_hands:
This underscore also shouldn’t be escaped as it’s in an emoji
code: :raised_hands:

And these ones should be eventually removed and <span class="underline">underline</span> the text (*Requires CSS to do so.*) &#x2013; **Org syntax**.
And these ones should be eventually removed and <span class="underline">underline</span> the text
(*Requires CSS to do so.*) &#x2013; **Org syntax**.
7 changes: 5 additions & 2 deletions example-site/content/posts/draft-state-draft.md
Expand Up @@ -5,6 +5,9 @@ tags = []
draft = true
+++

If a post has the `DRAFT` keyword too, the `draft` front matter variable should be set to `true`.
If a post has the `DRAFT` keyword too, the `draft` front matter variable
should be set to `true`.

Idea is to mark a post as `DRAFT` that you have already started writing, or are in the process at the moment, but it is not yet ready to be published
Idea is to mark a post as `DRAFT` that you have already started
writing, or are in the process at the moment, but it is not yet ready
to be published
6 changes: 4 additions & 2 deletions example-site/content/posts/draft-state-todo.md
Expand Up @@ -5,6 +5,8 @@ tags = []
draft = true
+++

If a post has the `TODO` keyword, the `draft` front matter variable should be set to `true`.
If a post has the `TODO` keyword, the `draft` front matter variable
should be set to `true`.

Idea to to mark a post or blog idea as `TODO` that you yet have to start writing.
Idea to to mark a post or blog idea as `TODO` that you yet have to
start writing.
3 changes: 2 additions & 1 deletion example-site/content/posts/image-captions.md
Expand Up @@ -7,4 +7,5 @@ draft = false

Some text before image.

{{<figure src="/images/org-mode-unicorn-logo.png" caption="A unicorn!">}} Some more text, after image.
{{<figure src="/images/org-mode-unicorn-logo.png" caption="A unicorn!">}}
Some more text, after image.
12 changes: 8 additions & 4 deletions example-site/content/posts/image-links.md
Expand Up @@ -14,7 +14,8 @@ This is some text before the first heading of this post.

---

~~To be fixed~~ (**Now fixed**): The sub-headings in a post get exported as *Heading 1* instead of *Heading 2*.
~~To be fixed~~ (**Now fixed**): The sub-headings in a post get exported as *Heading 1*
instead of *Heading 2*.

For example, this sub-section&rsquo;s heading is exported as:

Expand All @@ -32,7 +33,8 @@ instead of

**Solution**: Above is fixed by setting `HUGO_OFFSET_LEVEL` to 1.

So the sub-heading title and the post title both get the *Heading 1* tag and look the same size.
So the sub-heading title and the post title both get the *Heading 1*
tag and look the same size.


## Clickable link that opens the image (works!) {#clickable-link-that-opens-the-image--works}
Expand All @@ -42,9 +44,11 @@ So the sub-heading title and the post title both get the *Heading 1* tag and loo

## Clickable image that opens the image (works!) {#clickable-image-that-opens-the-image--works}

Click below image to jump to the unicorn image. [{{<figure src="/images/org-mode-unicorn-logo.png">}}](/images/org-mode-unicorn-logo.png)
Click below image to jump to the unicorn image.
[{{<figure src="/images/org-mode-unicorn-logo.png">}}](/images/org-mode-unicorn-logo.png)

- **NOTE:** `file:` has to be used in both Link and Description components of the Org link.
- **NOTE:** `file:` has to be used in both Link and Description components
of the Org link.


## Image with `ATTR_HTML` [Issue # 17](https://github.com/kaushalmodi/ox-hugo/issues/17) {#image-with-attr-html-issue-17}
Expand Down
Expand Up @@ -8,4 +8,5 @@ draft = false
weight = 50
+++

For this post, we see that no menu properties are inherited from the parent; only the menu properties set in his subtree are effective.
For this post, we see that no menu properties are inherited from the
parent; only the menu properties set in his subtree are effective.
Expand Up @@ -9,9 +9,11 @@ draft = false
identifier = "ov-partial"
+++

For this post, we should see just the menu *weight* and *identifier* properties get overridden.
For this post, we should see just the menu *weight* and *identifier*
properties get overridden.

You need to set unique menu identifiers, else you get a Hugo error like this:
You need to set unique menu identifiers, else you get a Hugo error
like this:

```text
ERROR 2017/07/18 12:32:14 Two or more menu items have the same name/identifier in Menu "main": "menu-meta-data-in-yaml-front-matter".
Expand Down
7 changes: 5 additions & 2 deletions example-site/content/posts/menu-meta-data-yaml.md
Expand Up @@ -10,6 +10,9 @@ menu :
parent : "posts"
---

Testing the addition of *menu* meta data to the YAML front matter. Here the front matter format is set to YAML using the `#+HUGO_FRONT_MATTER_FORMAT` keyword.
Testing the addition of *menu* meta data to the YAML front
matter. Here the front matter format is set to YAML using the
`#+HUGO_FRONT_MATTER_FORMAT` keyword.

Later only the *weight* and *identifier* menu properties are overridden using `EXPORT_HUGO_MENU_OVERRIDE` key in the property drawer.
Later only the *weight* and *identifier* menu properties are
overridden using `EXPORT_HUGO_MENU_OVERRIDE` key in the property drawer.
4 changes: 3 additions & 1 deletion example-site/content/posts/menu-meta-data-yaml2.md
Expand Up @@ -9,6 +9,8 @@ menu :
weight : 25
---

Testing the addition of *menu* meta data to the YAML front matter. Here the front matter format is set to YAML using the `HUGO_FRONT_MATTER_FORMAT` key in property drawer.
Testing the addition of *menu* meta data to the YAML front matter.
Here the front matter format is set to YAML using the
`HUGO_FRONT_MATTER_FORMAT` key in property drawer.

Here there is white space in menu entry keyword.
4 changes: 3 additions & 1 deletion example-site/content/posts/menu-meta-data-yaml3.md
Expand Up @@ -11,6 +11,8 @@ menu :
name : "Menu in YAML"
---

Testing the addition of *menu* meta data to the YAML front matter. Here the front matter format is set to YAML using the `HUGO_FRONT_MATTER_FORMAT` key in property drawer.
Testing the addition of *menu* meta data to the YAML front matter.
Here the front matter format is set to YAML using the
`HUGO_FRONT_MATTER_FORMAT` key in property drawer.

Here there is white space in menu name property.
4 changes: 3 additions & 1 deletion example-site/content/posts/multi-ref-same-footnote.md
Expand Up @@ -5,6 +5,8 @@ tags = ["footnote"]
draft = false
+++

This is some text[^fn:1]. This is some text[^fn:1]. This is some text[^fn:1].
This is some text[^fn:1].
This is some text[^fn:1].
This is some text[^fn:1].

[^fn:1]: First footnote
3 changes: 2 additions & 1 deletion example-site/content/posts/prep.md
Expand Up @@ -5,7 +5,8 @@ tags = []
draft = false
+++

1. Be the root directory for this Hugo site (the directory containing `config.toml`).
1. Be the root directory for this Hugo site (the directory containing
`config.toml`).
2. Run

```text
Expand Down
15 changes: 11 additions & 4 deletions example-site/content/posts/shortcode-src-blocks.md
Expand Up @@ -13,19 +13,26 @@ Here are few variables that you might like to change in the `local.mk`:
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
{{< /highlight >}}

The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by default. If you&rsquo;d like to change that, you can tweak the `lispdir` variable.
- **`infodir`:** Org Info installation directory. I like to keep the Info file for development version of Org in a separate directory.
The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you&rsquo;d like to change that, you can tweak the
`lispdir` variable.
- **`infodir`:** Org Info installation directory. I like to keep the
Info file for development version of Org in a separate
directory.

{{< highlight makefile>}}
infodir = $(prefix)/org/info # Default: $(prefix)/info
{{< /highlight >}}
- **`ORG_MAKE_DOC`:** Types of Org documentation you&rsquo;d like to build by default.
- **`ORG_MAKE_DOC`:** Types of Org documentation you&rsquo;d like to build by
default.

{{< highlight makefile>}}
# Define below you only need info documentation, the default includes html and pdf
ORG_MAKE_DOC = info pdf card # html
{{< /highlight >}}
- **`ORG_ADD_CONTRIB`:** Packages from the `contrib/` directory that you&rsquo;d like to build along with Org. Below are the ones on my *must-have* list.
- **`ORG_ADD_CONTRIB`:** Packages from the `contrib/` directory that
you&rsquo;d like to build along with Org. Below are the ones on my
*must-have* list.

{{< highlight makefile>}}
# Define if you want to include some (or all) files from contrib/lisp
Expand Down
4 changes: 3 additions & 1 deletion example-site/content/singles/post-draft.md
Expand Up @@ -12,7 +12,9 @@ draft = true
weight = 10
+++

This is a single post. You do not need to set the `EXPORT_FILE_NAME` property in here. But then you also lose the tag and property inheritance, TODO state, etc. Org awesomeness.
This is a single post. You do not need to set the `EXPORT_FILE_NAME`
property in here. But then you also lose the tag and property
inheritance, TODO state, etc. Org awesomeness.


## First heading in this post {#first-heading-in-this-post}
Expand Down
4 changes: 3 additions & 1 deletion example-site/content/singles/post-toml.md
Expand Up @@ -11,7 +11,9 @@ categories = ["cat1", "cat2"]
identifier = "single-toml"
+++

This is a single post. You do not need to set the `EXPORT_FILE_NAME` property in here. But then you also lose the tag and property inheritance Org awesomeness.
This is a single post. You do not need to set the `EXPORT_FILE_NAME`
property in here. But then you also lose the tag and property
inheritance Org awesomeness.


## First heading in this post {#first-heading-in-this-post}
Expand Down
4 changes: 3 additions & 1 deletion example-site/content/singles/post-yaml.md
Expand Up @@ -12,7 +12,9 @@ menu :
identifier : "single-yaml"
---

This is a single post. You do not need to set the `EXPORT_FILE_NAME` property in here. But then you also lose the tag and property inheritance, TODO state, etc. Org awesomeness.
This is a single post. You do not need to set the `EXPORT_FILE_NAME`
property in here. But then you also lose the tag and property
inheritance, TODO state, etc. Org awesomeness.


## First heading in this post {#first-heading-in-this-post}
Expand Down
3 changes: 2 additions & 1 deletion ox-hugo.el
Expand Up @@ -129,9 +129,10 @@ directory where all Hugo posts should go by default."

;; KEY KEYWORD OPTION DEFAULT BEHAVIOR
:options-alist '(;; Non-front-matter options
(:with-toc nil "toc" nil) ;No TOC by default
(:preserve-breaks nil "\\n" t) ;Preserve breaks so that text filling in Markdown matches that of Org
(:hugo-front-matter-format "HUGO_FRONT_MATTER_FORMAT" nil org-hugo-front-matter-format)
(:hugo-level-offset "HUGO_LEVEL_OFFSET" nil 1)
(:with-toc nil "toc" nil) ;No TOC by default
(:hugo-section "HUGO_SECTION" nil org-hugo-default-section-directory)
(:hugo-base-dir "HUGO_BASE_DIR" nil nil)
(:hugo-static-images "HUGO_STATIC_IMAGES" nil "images")
Expand Down

0 comments on commit 1f62a39

Please sign in to comment.