!6 Fix occasional failure of rubygem-wikicloth
From: @starlet-dx Reviewed-by: @jxy_git Signed-off-by: @jxy_git
This commit is contained in:
commit
4eba451f08
89
make-locale-change-local-to-wiki-rendering.patch
Normal file
89
make-locale-change-local-to-wiki-rendering.patch
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
From f683a831cc361438a35c4df3fc7a07d9eab37109 Mon Sep 17 00:00:00 2001
|
||||||
|
From: katafrakt <inquebrantable@gmail.com>
|
||||||
|
Date: Sun, 8 Feb 2015 15:52:26 +0100
|
||||||
|
Subject: [PATCH] make locale change local to wiki rendering
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/wikicloth.rb | 62 +++++++++++++++++++++++++-----------------------
|
||||||
|
1 file changed, 32 insertions(+), 30 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/wikicloth.rb b/lib/wikicloth.rb
|
||||||
|
index c0ad932..e096c2c 100644
|
||||||
|
--- a/lib/wikicloth.rb
|
||||||
|
+++ b/lib/wikicloth.rb
|
||||||
|
@@ -58,43 +58,45 @@ def load(data,p={})
|
||||||
|
end
|
||||||
|
|
||||||
|
def render(opt={})
|
||||||
|
- self.options = { :noedit => false, :locale => I18n.default_locale, :fast => true, :output => :html, :link_handler => self.link_handler,
|
||||||
|
+ self.options = { :noedit => false, :fast => true, :output => :html, :link_handler => self.link_handler,
|
||||||
|
:params => self.params, :sections => self.sections }.merge(self.options).merge(opt)
|
||||||
|
self.options[:link_handler].params = options[:params]
|
||||||
|
|
||||||
|
- I18n.locale = self.options[:locale]
|
||||||
|
-
|
||||||
|
- data = self.sections.collect { |s| s.render(self.options) }.join
|
||||||
|
- data.gsub!(/<!--(.|\s)*?-->/,"")
|
||||||
|
- data << "\n" if data.last(1) != "\n"
|
||||||
|
- data << "garbage"
|
||||||
|
-
|
||||||
|
- buffer = WikiBuffer.new("",options)
|
||||||
|
-
|
||||||
|
- begin
|
||||||
|
- if self.options[:fast]
|
||||||
|
- until data.empty?
|
||||||
|
- case data
|
||||||
|
- when /\A\w+/
|
||||||
|
- data = $'
|
||||||
|
- @current_row += $&.length
|
||||||
|
- buffer.add_word($&)
|
||||||
|
- when /\A[^\w]+(\w|)/m
|
||||||
|
- data = $'
|
||||||
|
- $&.each_char { |c| add_current_char(buffer,c) }
|
||||||
|
+ locale = self.options[:locale] || I18n.locale
|
||||||
|
+
|
||||||
|
+ I18n.with_locale(locale) do
|
||||||
|
+ data = self.sections.collect { |s| s.render(self.options) }.join
|
||||||
|
+ data.gsub!(/<!--(.|\s)*?-->/,"")
|
||||||
|
+ data << "\n" if data.last(1) != "\n"
|
||||||
|
+ data << "garbage"
|
||||||
|
+
|
||||||
|
+ buffer = WikiBuffer.new("",options)
|
||||||
|
+
|
||||||
|
+ begin
|
||||||
|
+ if self.options[:fast]
|
||||||
|
+ until data.empty?
|
||||||
|
+ case data
|
||||||
|
+ when /\A\w+/
|
||||||
|
+ data = $'
|
||||||
|
+ @current_row += $&.length
|
||||||
|
+ buffer.add_word($&)
|
||||||
|
+ when /\A[^\w]+(\w|)/m
|
||||||
|
+ data = $'
|
||||||
|
+ $&.each_char { |c| add_current_char(buffer,c) }
|
||||||
|
+ end
|
||||||
|
end
|
||||||
|
+ else
|
||||||
|
+ data.each_char { |c| add_current_char(buffer,c) }
|
||||||
|
end
|
||||||
|
- else
|
||||||
|
- data.each_char { |c| add_current_char(buffer,c) }
|
||||||
|
+ rescue => err
|
||||||
|
+ debug_tree = buffer.buffers.collect { |b| b.debug }.join("-->")
|
||||||
|
+ puts I18n.t("unknown error on line", :line => @current_line, :row => @current_row, :tree => debug_tree)
|
||||||
|
+ raise err
|
||||||
|
end
|
||||||
|
- rescue => err
|
||||||
|
- debug_tree = buffer.buffers.collect { |b| b.debug }.join("-->")
|
||||||
|
- puts I18n.t("unknown error on line", :line => @current_line, :row => @current_row, :tree => debug_tree)
|
||||||
|
- raise err
|
||||||
|
- end
|
||||||
|
|
||||||
|
- buffer.eof()
|
||||||
|
- buffer.send("to_#{self.options[:output]}")
|
||||||
|
+ buffer.eof()
|
||||||
|
+ buffer.send("to_#{self.options[:output]}")
|
||||||
|
+ end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sections
|
||||||
@ -1,7 +1,7 @@
|
|||||||
%global gem_name wikicloth
|
%global gem_name wikicloth
|
||||||
Name: rubygem-%{gem_name}
|
Name: rubygem-%{gem_name}
|
||||||
Version: 0.8.0
|
Version: 0.8.0
|
||||||
Release: 2
|
Release: 3
|
||||||
Summary: Mediawiki parser
|
Summary: Mediawiki parser
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/nricciar/wikicloth
|
URL: https://github.com/nricciar/wikicloth
|
||||||
@ -9,6 +9,9 @@ Source0: https://rubygems.org/gems/wikicloth-%{version}.gem
|
|||||||
Patch0: rubygem-wikicloth-0.8.0-minitest.patch
|
Patch0: rubygem-wikicloth-0.8.0-minitest.patch
|
||||||
Patch1: rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch
|
Patch1: rubygem-wikicloth-0.8.3-add-a-condition-to-avoid-FrozenError.patch
|
||||||
Patch2: Fix-build-error.patch
|
Patch2: Fix-build-error.patch
|
||||||
|
# https://github.com/nricciar/wikicloth/issue/58
|
||||||
|
# https://github.com/nricciar/wikicloth/pull/79
|
||||||
|
Patch3: make-locale-change-local-to-wiki-rendering.patch
|
||||||
Requires: ruby(release) ruby(rubygems) rubygem(builder) rubygem(expression_parser)
|
Requires: ruby(release) ruby(rubygems) rubygem(builder) rubygem(expression_parser)
|
||||||
BuildRequires: ruby(release) rubygems-devel rubygem(activesupport) rubygem(builder)
|
BuildRequires: ruby(release) rubygems-devel rubygem(activesupport) rubygem(builder)
|
||||||
BuildRequires: rubygem(expression_parser) rubygem(rexml)
|
BuildRequires: rubygem(expression_parser) rubygem(rexml)
|
||||||
@ -31,6 +34,7 @@ gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
|||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
for f in .gitignore .travis.yml Gemfile Rakefile run_tests.rb tasks/wikicloth_tasks.rake; do
|
for f in .gitignore .travis.yml Gemfile Rakefile run_tests.rb tasks/wikicloth_tasks.rake; do
|
||||||
rm $f
|
rm $f
|
||||||
sed -i "s|\"$f\".freeze,||g" %{gem_name}.gemspec
|
sed -i "s|\"$f\".freeze,||g" %{gem_name}.gemspec
|
||||||
@ -69,6 +73,9 @@ popd
|
|||||||
%{gem_instdir}/sample_documents
|
%{gem_instdir}/sample_documents
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 15 2022 yaoxin <yaoxin30@h-partners.com> - 0.8.0-3
|
||||||
|
- Fix occasional failure of rubygem-wikicloth
|
||||||
|
|
||||||
* Wed Feb 9 2022 yanan li <liyanan32@huawei.com> - 0.8.0-2
|
* Wed Feb 9 2022 yanan li <liyanan32@huawei.com> - 0.8.0-2
|
||||||
- Fix build error
|
- Fix build error
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user