iPython+notebook syntax highlighting and allowing data:image uris

pull/511/head
japborst 8 years ago committed by Thibaut Courouble
parent c4a543933d
commit 8e2e150be1

@ -11,6 +11,7 @@ module Docs
def update_attribute(tag, attribute) def update_attribute(tag, attribute)
css(tag.to_s).each do |node| css(tag.to_s).each do |node|
next if node[attribute].start_with?('data:image')
next unless value = node[attribute] next unless value = node[attribute]
next if fragment_url_string?(value) next if fragment_url_string?(value)
node[attribute] = normalize_url(value) node[attribute] = normalize_url(value)

@ -20,10 +20,18 @@ module Docs
css('div[class*="highlight-"]').each do |node| css('div[class*="highlight-"]').each do |node|
pre = node.at_css('pre') pre = node.at_css('pre')
pre.content = pre.content pre.content = pre.content
pre['data-language'] = node['class'][/highlight\-(\w+)/, 1] lang = node['class'][/highlight\-(\w+)/, 1]
pre['data-language'] = 'php' if pre['data-language'] == 'ci' lang = 'php' if lang == 'ci'
pre['data-language'] = 'markup' if pre['data-language'] == 'html+django' lang = 'markup' if lang == 'html+django'
pre['data-language'] = 'python' if pre['data-language'] == 'default' || pre['data-language'].start_with?('python') lang = 'python' if lang == 'default' || lang.start_with?('python') || lang.start_with?('ipython')
pre['data-language'] = lang
node.replace(pre)
end
# Support code blocks in jupyter notebook files
css('.code_cell div.highlight').each do |node|
pre = node.at_css('pre')
pre['data-language'] = 'python'
node.replace(pre) node.replace(pre)
end end

Loading…
Cancel
Save