wallyqs / org-ruby

An Org mode parser written in Ruby.
218 stars 49 forks source link

Verbatim text with leading or trailing comma is not rendered with <code> tags #99

Open susam opened 1 year ago

susam commented 1 year ago

Here is an example program that reproduces the issue:

require 'org-ruby'

# The following verbatim examples are not rendered using <code> tags.
# Both pandoc and org-export-to-file render them using <code> tags.
puts Orgmode::Parser.new("=,foo=").to_html
puts Orgmode::Parser.new("=, foo=").to_html
puts Orgmode::Parser.new("=foo,=").to_html
puts

# The above issue does not seem to occur if the comma is somewhere in
# the middle. These are correctly rendered with <code> tags.
puts Orgmode::Parser.new("=foo,bar=").to_html
puts Orgmode::Parser.new("=foo, bar=").to_html
puts

# The issue mentioned earlier does not seem to occur if we use another
# punctuation instead of comma. These are rendered with <code> tags too.
puts Orgmode::Parser.new("=;foo=").to_html
puts Orgmode::Parser.new("=; foo=").to_html
puts Orgmode::Parser.new("=foo;=").to_html
puts

puts Orgmode::Parser.new("=.foo=").to_html
puts Orgmode::Parser.new("=. foo=").to_html
puts Orgmode::Parser.new("=foo.=").to_html
puts

puts Orgmode::Parser.new("=:foo=").to_html
puts Orgmode::Parser.new("=: foo=").to_html
puts Orgmode::Parser.new("=foo:=").to_html
puts

puts Orgmode::Parser.new("=-foo=").to_html
puts Orgmode::Parser.new("=- foo=").to_html
puts Orgmode::Parser.new("=foo-=").to_html
puts

Here is the output:

<p>=,foo=</p>
<p>=, foo=</p>
<p>=foo,=</p>

<p><code>foo,bar</code></p>
<p><code>foo, bar</code></p>

<p><code>;foo</code></p>
<p><code>; foo</code></p>
<p><code>foo;</code></p>

<p><code>.foo</code></p>
<p><code>. foo</code></p>
<p><code>foo.</code></p>

<p><code>:foo</code></p>
<p><code>: foo</code></p>
<p><code>foo:</code></p>

<p><code>-foo</code></p>
<p><code>- foo</code></p>
<p><code>foo-</code></p>

However, the first three lines of output should be:

<p><code>=,foo=</code></p>
<p><code>=, foo=</code></p>
<p><code>=foo,=</code></p>
susam commented 1 year ago

Here is a minimal demonstration that shows that the first three lines in the previous example are supposed to be rendered with <code> tags:

cat <<EOF > foo.org
* Demo
- =,foo=
- =, foo=
- =foo,=
EOF

pandoc foo.org -o foo.pandoc.html
grep '<li>' foo.pandoc.html
echo

emacs --batch \
      --eval "(find-file \"foo.org\")" \
      --eval "(org-export-to-file 'html \"foo.emacs.html\")" \
      --eval "(kill-emacs)"
grep '<li>' foo.emacs.html

Output:

<li><code class="verbatim">,foo</code></li>
<li><code class="verbatim">, foo</code></li>
<li><code class="verbatim">foo,</code></li>

<li><a href="#orgee10651">1. Demo</a></li>
<li><code>,foo</code></li>
<li><code>, foo</code></li>
<li><code>foo,</code></li>