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/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 5d18f8d..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|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}\"" 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 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' }