From 45b451d47bf11a5f5d9d65c15966a93de19f0165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=B8=E0=A4=AE=E0=A5=80=E0=A4=B0=20=E0=A4=B8=E0=A4=BF?= =?UTF-8?q?=E0=A4=82=E0=A4=B9=20Sameer=20Singh?= Date: Fri, 13 Mar 2026 08:43:49 +0530 Subject: [PATCH 1/3] add support for webp images --- lib/org-ruby/image_regexp.rb | 2 +- lib/org-ruby/regexp_helper.rb | 2 +- spec/html_examples/include-file.html | 10 ++++++---- spec/html_examples/inline-images.html | 1 + spec/html_examples/inline-images.org | 1 + spec/markdown_examples/inline-images.md | 1 + spec/markdown_examples/inline-images.org | 1 + spec/org-ruby/image_regexp_spec.rb | 1 + 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/org-ruby/image_regexp.rb b/lib/org-ruby/image_regexp.rb index 6fc9db4..3ddc880 100644 --- a/lib/org-ruby/image_regexp.rb +++ b/lib/org-ruby/image_regexp.rb @@ -1,7 +1,7 @@ module Orgmode module ImageRegexp def image_file - /\.(gif|jpe?g|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i + /\.(gif|jpe?g|webp|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i end end end diff --git a/lib/org-ruby/regexp_helper.rb b/lib/org-ruby/regexp_helper.rb index 5d18f8d..29d6c92 100644 --- a/lib/org-ruby/regexp_helper.rb +++ b/lib/org-ruby/regexp_helper.rb @@ -171,7 +171,7 @@ def org_emphasis_regexp end def org_image_file_regexp - /\.(gif|jpe?g|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i + /\.(gif|jpe?g|webp|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i end private diff --git a/spec/html_examples/include-file.html b/spec/html_examples/include-file.html index cb8ab74..c0b0535 100644 --- a/spec/html_examples/include-file.html +++ b/spec/html_examples/include-file.html @@ -77,10 +77,10 @@

Continue numbered list

And now back to normal!

Within a commented block

-<li>[ ] &#8220;smart quotes&#8221;</li> 
-<li>[ ] I think I need this for &#8216;single quotes&#8217; too. Don&#8217;t I?</li> 
-<li>[ ] Em dashes would be great &#8212; wouldn&#8217;t they?</li> 
-<li>[ ] I hope to develop an en dash sometime in 2010 &#8211; 2011.</li> 
+<li>[ ] &#8220;smart quotes&#8221;</li>
+<li>[ ] I think I need this for &#8216;single quotes&#8217; too. Don&#8217;t I?</li>
+<li>[ ] Em dashes would be great &#8212; wouldn&#8217;t they?</li>
+<li>[ ] I hope to develop an en dash sometime in 2010 &#8211; 2011.</li>
 

Within a center block

@@ -98,6 +98,7 @@

Within a center block

  • .jpeg
  • .svg
  • .svgz
  • +
  • .webp
  • Sample absolute link to .svg:

    https://www.w3.org/Graphics/SVG/Test/20110816/svg/animate-dom-01-f.svg

    @@ -129,6 +130,7 @@

    Within a blockquote

  • .jpeg
  • .svg
  • .svgz
  • +
  • .webp
  • Sample absolute link to .svg:

    https://www.w3.org/Graphics/SVG/Test/20110816/svg/animate-dom-01-f.svg

    diff --git a/spec/html_examples/inline-images.html b/spec/html_examples/inline-images.html index 81cc074..9705747 100644 --- a/spec/html_examples/inline-images.html +++ b/spec/html_examples/inline-images.html @@ -11,6 +11,7 @@
  • .jpeg
  • .svg
  • .svgz
  • +
  • .webp
  • Sample absolute link to .svg:

    https://www.w3.org/Graphics/SVG/Test/20110816/svg/animate-dom-01-f.svg

    diff --git a/spec/html_examples/inline-images.org b/spec/html_examples/inline-images.org index 5e93af3..74f3297 100644 --- a/spec/html_examples/inline-images.org +++ b/spec/html_examples/inline-images.org @@ -14,6 +14,7 @@ the inline image. I recognize the following image file types: - .jpeg - .svg - .svgz +- .webp Sample absolute link to .svg: diff --git a/spec/markdown_examples/inline-images.md b/spec/markdown_examples/inline-images.md index fef912e..fc45b4c 100644 --- a/spec/markdown_examples/inline-images.md +++ b/spec/markdown_examples/inline-images.md @@ -14,6 +14,7 @@ the inline image. I recognize the following image file types: * .jpeg * .svg * .svgz + * .webp Sample .svg: diff --git a/spec/markdown_examples/inline-images.org b/spec/markdown_examples/inline-images.org index 3f85ac0..39b4df6 100644 --- a/spec/markdown_examples/inline-images.org +++ b/spec/markdown_examples/inline-images.org @@ -14,6 +14,7 @@ the inline image. I recognize the following image file types: - .jpeg - .svg - .svgz +- .webp Sample .svg: diff --git a/spec/org-ruby/image_regexp_spec.rb b/spec/org-ruby/image_regexp_spec.rb index 64af06a..02e8576 100644 --- a/spec/org-ruby/image_regexp_spec.rb +++ b/spec/org-ruby/image_regexp_spec.rb @@ -15,6 +15,7 @@ class DummyRegexp it { expect(regexp.image_file).to match 'some/path/file.gif' } it { expect(regexp.image_file).to match 'other.svgz' } it { expect(regexp.image_file).to match 'tiffany.tiff' } + it { expect(regexp.image_file).to match 'file.webp' } it { expect(regexp.image_file).to match 'xx.xpm' } it { expect(regexp.image_file).to match 'yy.xbm' } From 620dd3762776dbe7552111df6a6e64ef2099c5a5 Mon Sep 17 00:00:00 2001 From: Ricardo Arredondo Date: Tue, 12 May 2026 23:14:16 -0600 Subject: [PATCH 2/3] Fix tests: Remove trailing whitespaces from escape-pre example. --- spec/html_examples/escape-pre.html | 8 ++++---- spec/html_examples/escape-pre.org | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/html_examples/escape-pre.html b/spec/html_examples/escape-pre.html index 0671519..125df07 100644 --- a/spec/html_examples/escape-pre.html +++ b/spec/html_examples/escape-pre.html @@ -1,6 +1,6 @@
    -<li>[ ] &#8220;smart quotes&#8221;</li> 
    -<li>[ ] I think I need this for &#8216;single quotes&#8217; too. Don&#8217;t I?</li> 
    -<li>[ ] Em dashes would be great &#8212; wouldn&#8217;t they?</li> 
    -<li>[ ] I hope to develop an en dash sometime in 2010 &#8211; 2011.</li> 
    +<li>[ ] &#8220;smart quotes&#8221;</li>
    +<li>[ ] I think I need this for &#8216;single quotes&#8217; too. Don&#8217;t I?</li>
    +<li>[ ] Em dashes would be great &#8212; wouldn&#8217;t they?</li>
    +<li>[ ] I hope to develop an en dash sometime in 2010 &#8211; 2011.</li>
     
    diff --git a/spec/html_examples/escape-pre.org b/spec/html_examples/escape-pre.org index abcb4a7..0635b87 100644 --- a/spec/html_examples/escape-pre.org +++ b/spec/html_examples/escape-pre.org @@ -1,6 +1,6 @@ #+BEGIN_EXAMPLE -
  • [ ] “smart quotes”
  • -
  • [ ] I think I need this for ‘single quotes’ too. Don’t I?
  • -
  • [ ] Em dashes would be great — wouldn’t they?
  • -
  • [ ] I hope to develop an en dash sometime in 2010 – 2011.
  • - #+END_EXAMPLE +
  • [ ] “smart quotes”
  • +
  • [ ] I think I need this for ‘single quotes’ too. Don’t I?
  • +
  • [ ] Em dashes would be great — wouldn’t they?
  • +
  • [ ] I hope to develop an en dash sometime in 2010 – 2011.
  • + #+END_EXAMPLE From 8ec25ae47195050ee8800cfcfec0d9e986ff73ce Mon Sep 17 00:00:00 2001 From: Ricardo Arredondo Date: Tue, 12 May 2026 23:19:57 -0600 Subject: [PATCH 3/3] Remove org_image_file_regexp --- lib/org-ruby/markdown_output_buffer.rb | 4 ++-- lib/org-ruby/regexp_helper.rb | 4 ---- lib/org-ruby/textile_output_buffer.rb | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/org-ruby/markdown_output_buffer.rb b/lib/org-ruby/markdown_output_buffer.rb index 418ee4a..649c236 100644 --- a/lib/org-ruby/markdown_output_buffer.rb +++ b/lib/org-ruby/markdown_output_buffer.rb @@ -49,10 +49,10 @@ def inline_formatting(input) @re_help.rewrite_links input do |link, defi| # We don't add a description for images in links, because its # empty value forces the image to be inlined. - defi ||= link unless link =~ @re_help.org_image_file_regexp + defi ||= link unless RegexpHelper.image_file.match(link) link = link.gsub(/ /, "%%20") - if defi =~ @re_help.org_image_file_regexp + if RegexpHelper.image_file.match(defi) "![#{defi}](#{defi})" elsif defi "[#{defi}](#{link})" diff --git a/lib/org-ruby/regexp_helper.rb b/lib/org-ruby/regexp_helper.rb index 29d6c92..26c1250 100644 --- a/lib/org-ruby/regexp_helper.rb +++ b/lib/org-ruby/regexp_helper.rb @@ -170,10 +170,6 @@ def org_emphasis_regexp "(?=#{post_emphasis})") end - def org_image_file_regexp - /\.(gif|jpe?g|webp|p(?:bm|gm|n[gm]|pm)|svgz?|tiff?|x[bp]m)/i - end - private def pre_emphasis_regexp diff --git a/lib/org-ruby/textile_output_buffer.rb b/lib/org-ruby/textile_output_buffer.rb index 0c5bf8e..7271ca9 100644 --- a/lib/org-ruby/textile_output_buffer.rb +++ b/lib/org-ruby/textile_output_buffer.rb @@ -61,10 +61,10 @@ def inline_formatting(input) # We don't add a description for images in links, because its # empty value forces the image to be inlined. - defi ||= link unless link =~ @re_help.org_image_file_regexp + defi ||= link unless RegexpHelper.image_file.match(link) link = link.gsub(/ /, "%%20") - if defi =~ @re_help.org_image_file_regexp + if RegexpHelper.image_file.match(defi) defi = "!#{defi}(#{defi})!" elsif defi defi = "\"#{defi}\""