Tag: html entities

Ruby gem安装和“没有这样的文件加载”

我在Backtrack 5中使用Ruby 1.9.2dev编写脚本但是在尝试使用库“htmlentities”解析html实体时遇到了一些问题。 虽然我已经安装了gem,但我无法加载库。 我将向您展示我在控制台中遇到的问题: root@bt:~# gem list -d htmlentities *** LOCAL GEMS *** htmlentities (4.3.1) Author: Paul Battley Homepage: https://github.com/threedaymonk/htmlentities Installed at: /var/lib/gems/1.9.2 A module for encoding and decoding (X)HTML entities. root@bt:~# irb irb(main):001:0> require ‘htmlentities’ LoadError: no such file to load — htmlentities from (irb):1:in `require’ from (irb):1 from /usr/bin/irb:12:in `’ 这与我和nokogiri有同样的问题。 我安装了库 […]

Ruby json gem编码html实体

我在我的代码中创建了一个名为timeOffsets的哈希 @timeOffsets = Hash.new total=0 @sections.each do |i| @timeOffsets[i.shortcode] = total total+=i.length end 我使用to_json在Javascript中渲染它,: timeOffsets=; 但我用编码的HTML实体得到它: timeOffsets={"Introduction_to_Lists":0,"Removing_elements":693,"Joining__join_":1490}; 如何阻止它编码HTML实体?

Rspec测试页面内容中的html实体

我正在编写请求规范,并希望测试字符串“Reports»Aging Reports”的存在。 我得到一个错误(无效的多字节字符),如果我直接在我的匹配表达式中输入字符,所以我尝试了这个: page.should have_content(“Reports » Aging Reports”) 这使测试失败并显示以下消息: expected there to be content “Reports » Aging Reports” in “\n Reports » Aging Reports\n 我尝试过像.html_safe这样的东西没有成功。 有没有办法测试包含html实体的文本? 编辑: 这是html源代码的相关区域: Reports » Aging Reports

如何让Nokogiri不要转换  到太空

我拿一个像html一样的html片段 “市 场 价” 其中包含“   ”,但在调用Nokogiri NodeSet的to_s之后,它就变成了 “市 场 价” ,我想保留原始的html片段,并尝试设置:save_with option方法的:save_with option ,但失败了。 有人会遇到同样的问题并给我帮助吗? 先感谢您。