public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rubygem-kramdown] rawhide: Backport upstream change for StringScanner implementation needed for ruby4.1
Date: Sun, 15 Nov 2026 13:11:48 GMT	[thread overview]
Message-ID: <179474830885.1.362238740863532928.rpms-rubygem-kramdown-18f72374c200@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/rubygem-kramdown
            Branch : rawhide
            Commit : 18f72374c20042f26aad8487dd79899e6405723a
            Author : Mamoru TASAKA <mtasaka@fedoraproject.org>
            Date   : 2026-11-15T22:11:34+09:00
            Stats  : +115/-1 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/rubygem-kramdown/c/18f72374c20042f26aad8487dd79899e6405723a?branch=rawhide

            Log:
            Backport upstream change for StringScanner implementation needed for ruby4.1

Backport upstream change to suppress warnings for new Rouge

---
diff --git a/kramdown-9ebfac6-ruby41-stringscanner-impl-change.patch b/kramdown-9ebfac6-ruby41-stringscanner-impl-change.patch
new file mode 100644
index 0000000..cb6786f
--- /dev/null
+++ b/kramdown-9ebfac6-ruby41-stringscanner-impl-change.patch
@@ -0,0 +1,39 @@
+From 9ebfac62754434c7472dd8d0255bd8564f629e37 Mon Sep 17 00:00:00 2001
+From: Thomas Leitner <t_leitner@gmx.at>
+Date: Sat, 7 Nov 2026 00:21:41 +0100
+Subject: [PATCH] Increase performance of
+ Utils::StringScanner#current_line_number
+
+Instead of creating a new StringScanner on each invocation and searching
+for each newline separately, the newlines are now counted with
+String#count on a byte slice.
+---
+ lib/kramdown/utils/string_scanner.rb | 15 +++++++--------
+ 1 file changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/lib/kramdown/utils/string_scanner.rb b/lib/kramdown/utils/string_scanner.rb
+index de076903..44899e13 100644
+--- a/lib/kramdown/utils/string_scanner.rb
++++ b/lib/kramdown/utils/string_scanner.rb
+@@ -65,14 +65,13 @@ def revert_pos(data)
+       # NOTE: Normally we'd have to add one to the count of newlines to get the correct line number.
+       # However we add the one indirectly by using a one-based start_line_number.
+       def current_line_number
+-        # Not using string[@previous_pos..best_pos].count('\n') because it is slower
+-        strscan = ::StringScanner.new(string)
+-        strscan.pos = @previous_pos
+-        old_pos = pos + 1
+-        @previous_line_number += 1 while strscan.skip_until(/\n/) && strscan.pos <= old_pos
+-
+-        @previous_pos = (eos? ? pos : pos + 1)
+-        @previous_line_number
++        cur_pos = pos
++        if cur_pos > @previous_pos
++          @previous_line_number += string.byteslice(@previous_pos, cur_pos - @previous_pos).
++            force_encoding(Encoding::BINARY).count("\n")
++          @previous_pos = cur_pos
++        end
++        string.getbyte(cur_pos) == 10 ? @previous_line_number + 1 : @previous_line_number
+       end
+ 
+     end

diff --git a/kramdown-ad36bb9-suppress-rouge-formatter-deprecation-warning.patch b/kramdown-ad36bb9-suppress-rouge-formatter-deprecation-warning.patch
new file mode 100644
index 0000000..a5d988d
--- /dev/null
+++ b/kramdown-ad36bb9-suppress-rouge-formatter-deprecation-warning.patch
@@ -0,0 +1,62 @@
+From ad36bb92474232832af484b3751bde90912b580b Mon Sep 17 00:00:00 2001
+From: Thomas Leitner <t_leitner@gmx.at>
+Date: Sun, 1 Nov 2026 15:27:29 +0100
+Subject: [PATCH] Fix warning related to deprecated HTMLLegacy formatter of
+ Rouge
+
+---
+ doc/syntax_highlighter/rouge.page             |  8 ++---
+ .../converter/syntax_highlighter/rouge.rb     | 33 +++++++++++++++++--
+ 2 files changed, 35 insertions(+), 6 deletions(-)
+
+diff --git a/lib/kramdown/converter/syntax_highlighter/rouge.rb b/lib/kramdown/converter/syntax_highlighter/rouge.rb
+index a286c4d9..b9c21e2d 100644
+--- a/lib/kramdown/converter/syntax_highlighter/rouge.rb
++++ b/lib/kramdown/converter/syntax_highlighter/rouge.rb
+@@ -17,6 +17,36 @@ module Rouge
+ 
+       # Highlighting via Rouge is available if this constant is +true+.
+       AVAILABLE = true
++
++      # This is the HTMLLegacy implementation from Rouge that is deprecated. Therefore it is
++      # reproduced here and only adapted as needed.
++      class HTMLLegacy < ::Rouge::Formatter
++        def initialize(opts = {})
++          @formatter = if opts[:inline_theme]
++                         ::Rouge::Formatters::HTMLInline.new(opts[:inline_theme])
++                         else
++                         ::Rouge::Formatters::HTML.new
++                       end
++          @formatter = ::Rouge::Formatters::HTMLTable.new(@formatter, opts) if opts[:line_numbers]
++
++          if opts.fetch(:wrap, true)
++            @pygments_wrap = opts.fetch(:css_class, 'codehilite')
++          end
++        end
++
++        def stream(tokens, &b)
++          if @pygments_wrap
++            yield %(<div class="highlight"><pre class="#{@pygments_wrap}"><code>)
++          end
++
++          @formatter.stream(tokens, &b)
++
++          if @pygments_wrap
++            yield "</code></pre></div>"
++          end
++        end
++      end
++
+     rescue LoadError, SyntaxError
+       AVAILABLE = false # :nodoc:
+     end
+@@ -72,8 +102,7 @@ def self.formatter_class(opts = {})
+       when /\A[[:upper:]][[:alnum:]_]*\z/
+         ::Rouge::Formatters.const_get(formatter, false)
+       else
+-        # Available in Rouge 2.0 or later
+-        ::Rouge::Formatters::HTMLLegacy
++        HTMLLegacy
+       end
+     rescue NameError
+       # Fallback to Rouge 1.x

diff --git a/rubygem-kramdown.spec b/rubygem-kramdown.spec
index e635487..e844806 100644
--- a/rubygem-kramdown.spec
+++ b/rubygem-kramdown.spec
@@ -3,13 +3,19 @@
 
 Name: rubygem-%{gem_name}
 Version: 2.5.2
-Release: 4%{?dist}
+Release: 5%{?dist}
 Summary: Fast, pure-Ruby Markdown-superset converter
 
 # SPDX confirmed
 License:	MIT
 URL:		http://kramdown.gettalong.org
 Source0:	https://rubygems.org/gems/%{gem_name}-%{version}.gem
+# https://github.com/gettalong/kramdown/commit/ad36bb92474232832af484b3751bde90912b580b
+# Suppress Rouge formatter deprecation warning
+Patch0:	kramdown-ad36bb9-suppress-rouge-formatter-deprecation-warning.patch
+# https://github.com/gettalong/kramdown/commit/9ebfac62754434c7472dd8d0255bd8564f629e37
+# Utils::StringScanner#current_line_number implementation change, needed for ruby41
+Patch1:	kramdown-9ebfac6-ruby41-stringscanner-impl-change.patch
 BuildRequires:	ruby(release)
 BuildRequires:	rubygems-devel
 BuildRequires:	rubygem(minitest) >= 5
@@ -61,6 +67,9 @@ Documentation for %{name}
 %setup -q -n %{gem_name}-%{version}
 mv ../%{gem_name}-%{version}.gemspec .
 
+%patch -P0 -p1
+%patch -P1 -p1
+
 %build
 gem build %{gem_name}-%{version}.gemspec
 %gem_install
@@ -130,6 +139,10 @@ popd
 %doc	%{gem_docdir}
 
 %changelog
+* Sun Nov 15 2026 Mamoru TASAKA <mtasaka@fedoraproject.org> - 2.5.2-5
+- Backport upstream change for StringScanner implementation needed for ruby4.1
+- Backport upstream change to suppress warnings for new Rouge
+
 * Fri Jul 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

                 reply	other threads:[~2026-11-15 13:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179474830885.1.362238740863532928.rpms-rubygem-kramdown-18f72374c200@fedoraproject.org \
    --to=mtasaka@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox