-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: resolve {build_dir} in translated pages #2198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,12 +81,14 @@ def wrap_front_matter(front_matter) | |
| end | ||
|
|
||
| def expand_l10n(path, content, get_f_content, categories, ext) | ||
| content.gsub!(/include::({build_dir}\/)?(\S+)\.#{ext}/) do |line| | ||
| line.gsub!("include::", "") | ||
| if categories[line] | ||
| new_content = categories[line] | ||
| content.gsub!(/include::({build_dir}\/)?(\S+)\.#{ext}/) do | ||
| match = Regexp.last_match | ||
| target = "#{match[2]}.#{ext}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not extend the regular expression's second group so that |
||
| base = match[1] ? path.split("/", 2).first : File.dirname(path) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How certain can we be that |
||
| if categories[target] | ||
| new_content = categories[target] | ||
| else | ||
| new_content, new_path = get_f_content.call(path, line) | ||
| new_content, new_path = get_f_content.call(base, target) | ||
| end | ||
| if new_content | ||
| expand_l10n(new_path, new_content, get_f_content, categories, ext) | ||
|
|
@@ -230,8 +232,8 @@ def index_l10n_doc(filter_tags, doc_list, get_content) | |
|
|
||
| puts "Found #{doc_files.size} entries" | ||
|
|
||
| get_content_f = proc do |source, target| | ||
| name = File.join(File.dirname(source), target) | ||
| get_content_f = proc do |base, target| | ||
|
Comment on lines
-233
to
+235
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rename makes it unnecessarily hard to spot the actual functional change: removing the |
||
| name = File.join(base, target) | ||
| content_file = tag_files.detect { |ent| ent.first == name } | ||
| if content_file | ||
| new_content = get_content.call(content_file[1]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be done more elegantly via
|_, build_dir, path|? (I don't know, I'm no longer fluent in Ruby.)