Skip to content

Commit 3310fde

Browse files
committed
feat: add translate="no" attribute to block literal templates
This commit adds the `translate="no"` attribute to block literal templates to prevent machine translation tools from attempting to translate content within literal blocks. Literal blocks are typically used for command output, log files, and other pre-formatted text where exact spacing and formatting must be preserved. Changes include: - Added `translate="no"` attribute to the <pre> element in block_literal.html.erb - Added a comprehensive test in htmlbook_spec.rb to verify the attribute is correctly applied to literal blocks delimited with `....` This change complements the previous commits that added the same attribute to: 1. Inline code elements (via inline_quoted.html.erb) 2. Code blocks (via block_listing.html.erb) Together, these changes ensure that all code-like content throughout the documentation is excluded from translation by browser-based translation tools and other translation services, preserving the integrity of code examples, command output, and other technical content.
1 parent e5ce917 commit 3310fde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

htmlbook/block_literal.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%#encoding:UTF-8%><pre><%= content %></pre>
1+
<%#encoding:UTF-8%><pre translate="no"><%= content %></pre>

spec/htmlbook_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ def hello
303303
html = Nokogiri::HTML(convert(" This is also a literal block."))
304304
html.xpath("//pre").text.should == "This is also a literal block."
305305
end
306+
307+
it "should add translate='no' attribute to literal blocks" do
308+
html = Nokogiri::HTML(convert("
309+
....
310+
This is text in a literal block
311+
that should not be translated.
312+
....
313+
"))
314+
html.xpath("//pre/@translate").text.should == "no"
315+
end
306316

307317
# Test block_math template
308318
it "should convert math blocks" do

0 commit comments

Comments
 (0)