Skip to content

Commit

Permalink
Fix: Do not escape underscores in title in front matter
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Jul 28, 2017
1 parent 98c50ac commit f82f2c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example-site/content-org/all-posts.org
Expand Up @@ -132,12 +132,20 @@ Something 2.1
** Foo ( Bar ) Baz
** (Foo)Bar.Baz&Zoo
** Hey! I have a link [[https://example.org][here]] (Awesome!)
* Awesome title with "quoted text"
* Title in Front Matter
** Awesome title with "quoted text"
:PROPERTIES:
:EXPORT_FILE_NAME: post-title-quotes
:EXPORT_DATE: 2017-07-24
:END:
Testing a post with double quotes in the title.
** Under_scores_in_title
:PROPERTIES:
:EXPORT_FILE_NAME: under-scores-in-title
:EXPORT_DATE: 2017-07-28
:END:
Ensure that the underscores in =title= string of front matter do not
get escaped.. =foo_bar= must not become =foo\_bar=.
* Description meta-data with "quoted text"
:PROPERTIES:
:EXPORT_FILE_NAME: post-description-quotes
Expand Down
9 changes: 9 additions & 0 deletions example-site/content/posts/under-scores-in-title.md
@@ -0,0 +1,9 @@
+++
title = "Under_scores_in_title"
date = 2017-07-28
tags = []
draft = false
+++

Ensure that the underscores in `title` string of front matter do not
get escaped.. `foo_bar` must not become `foo\_bar`.
2 changes: 2 additions & 0 deletions ox-hugo.el
Expand Up @@ -698,6 +698,8 @@ INFO is a plist used as a communication channel."
(title (replace-regexp-in-string "\\\\?`" "" title))
(title (replace-regexp-in-string "\\`__?\\|\\`\\*\\*?\\|__?\\'\\|\\*\\*?\\'" "" title))
(title (replace-regexp-in-string " __?\\|__? \\| \\*\\*?\\|\\*\\*? " " " title))
;; Do not escape underscores in title
(title (replace-regexp-in-string "\\\\_" "_" title))

This comment has been minimized.

Copy link
@punchagan

punchagan Jul 29, 2017

Contributor

I had looked at this piece of code before, and was wondering if we should not be calling org-export-data on the title, at all. Any sort of mark-up in the title would usually be something unexpected.

This comment has been minimized.

Copy link
@kaushalmodi

kaushalmodi Jul 29, 2017

Author Owner

I tried that, but then plist-get was returning something like a hash or alist of meta-data + data. So plist-get would take the heading =ndash= and =mdash= and return that in 3 parts with the properties associated with each part.

I had realized that when I tried removing org-export-data and running C-c C-e H A. Also replacing org-export-data with plain format "%s" did not help.

I like the formatting in headings because they render well in org-mode.

I'm definitely looking for a cleaner way than current. If nothing else, then at least split out the title sanitization into a separate function.

This comment has been minimized.

Copy link
@kaushalmodi

kaushalmodi Jul 31, 2017

Author Owner

@punchagan

  • If nothing else, then at least split out the title sanitization into a separate function. f419f85
(menu-alist (org-hugo--parse-menu-prop-to-alist (plist-get info :hugo-menu)))
(menu-alist-override (org-hugo--parse-menu-prop-to-alist (plist-get info :hugo-menu-override)))
;; If menu-alist-override is non-nil, update menu-alist with values from that.
Expand Down

0 comments on commit f82f2c9

Please sign in to comment.