Skip to content

Commit 4fa3e38

Browse files
committed
View alt tags in development mode
1 parent ddf20f0 commit 4fa3e38

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

content/assets/stylesheets/docs_new.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ a.search-result, a.search-result:hover {
221221
margin: 20px 0px;
222222
padding: 10px;
223223
}
224+
225+
.image-caption {
226+
color: #666;
227+
border: 1px solid $pre-border-color;
228+
background-color: #f8f8f8;
229+
margin-top: -20px;
230+
margin-bottom: 0;
231+
padding: 5px;
232+
display: block;
233+
}
224234
}
225235

226236
#footer {

lib/common_marker_filter.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,20 @@ def code_block(node)
4444

4545
def image(node)
4646
url = node.url.sub(%r{^/content}, '')
47-
out('<img src="', escape_href(url), '"')
48-
plain do
49-
out(' alt="', :children, '"')
47+
48+
# Create a temporary renderer to get plain text of children
49+
alt = ''
50+
node.each do |child|
51+
if child.type == :text
52+
alt += child.string_content
53+
end
5054
end
55+
56+
out('<img src="', escape_href(url), '"')
57+
out(' alt="', escape_html(alt), '"')
5158
out(' title="', escape_html(node.title), '"') if node.title && !node.title.empty?
5259
out(" />")
60+
out('<span class="image-caption">', escape_html(alt), '</span>') if ENV['NANOC_ENV'] == 'development'
5361
end
5462
end
5563

0 commit comments

Comments
 (0)