org2blog / org2blog

Blog from Org mode to WordPress.

Home Page:https://github.com/org2blog/org2blog/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No space between listing number and caption when using the Plain Source Box Format

waveFrontSet opened this issue · comments

  • What did you do?
    (setq org2blog/wp-use-sourcecode-shortcode nil) and export an org document with source blocks to wordpress.
  • What did you expect to happen
    In particular, I expected a space between, say, "Listing 1." and the caption text of the first source block.
  • What happened instead?
    No space between them.
  • Did you review issue tracker to see if this bug is already
    reported or resolved?
    Yes.
  • Did you review the README about how this feature works?
    Yes.

Example

To make this a little clearer, here's a simple example:

#+caption: This is a caption
#+BEGIN_SRC python
print("Test.")
#+END_SRC

Using the Plain Source Box Format, this generates the following html when exporting to wordpress:

<label class="org-src-name"><em><span class="listing-number">Listing 1.</span>This is a caption. </em></label>

Note that there is no space between the closing span-Tag and the word "This".

Analysis

I suppose that the issue is that there is no space in between the two %s in the format string in the function ox-wp-src-block-html:

org2blog/ox-wp.el

Lines 168 to 170 in 5839812

(format "<label class=\"org-src-name\"><em>%s%s</em></label>"
listing-number
name-and-caption))

Note that using Syntax Highlighter Evolved works because a space is added after the variable footnote in the corresponding function ox-wp-src-block-shortcode:

org2blog/ox-wp.el

Lines 125 to 127 in 5839812

(title (concat footnote ". "
(when name (format "Name: %s. " name))
(when cap (format "%s. " cap))))

Hi @waveFrontSet . Thank you for the thoughtful and detailed report an analysis.

Certainly looks like that code is resonsible.

I will make the fix this week.

@waveFrontSet Just committed the change in v1.1.3.

I added the space and tidied up the logic a little bit.

My todo list has an entry to update the screenshots.

Let me know if you run into any issues.

Please close the issue if it is resolved.

Looks great! Thanks for the blazingly fast fix!

@waveFrontSet You are welcome. Thanks and have a great day.