Skip to content

Commit

Permalink
extract shared smallcaps method from TextTransformer#smallcaps_pcdata…
Browse files Browse the repository at this point in the history
… to make it easier to override
  • Loading branch information
mojavelinux committed Jan 20, 2024
1 parent 658d3c0 commit 188679f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Improvements::
* process `pre-wrap` role in text formatter
* drop support for the unmaintained payment font (`pf`) for use in font-based icons
* refactor formatted text transform to simplify how inner space is collapsed; verify only inner hard breaks are preserved
* extract shared `smallcaps` method from `TextTransform#smallcaps_pcdata` to make it easier to override

Bug Fixes::

Expand Down
8 changes: 6 additions & 2 deletions lib/asciidoctor/pdf/text_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ def uppercase_pcdata string

def smallcaps_pcdata string
if XMLMarkupRx.match? string
string.gsub(PCDATAFilterRx) { $2 ? ($2.tr LowerAlphaChars, SmallCapsChars) : $1 }
string.gsub(PCDATAFilterRx) { $2 ? (smallcaps $2) : $1 }
else
string.tr LowerAlphaChars, SmallCapsChars
smallcaps string
end
end

def smallcaps string
string.tr LowerAlphaChars, SmallCapsChars
end

# Apply the text transform to the specified text.
#
# Supported transform values are "uppercase", "lowercase", or "none" (passed
Expand Down

0 comments on commit 188679f

Please sign in to comment.