Class: ZhihuSyncer
- Inherits:
-
PerNodeSyncer
- Object
- AbstractSyncer
- PerNodeSyncer
- ZhihuSyncer
- Defined in:
- lib/syncers/zhihu_syncer.rb
Constant Summary
Constants included from NodeAttrModule
Instance Method Summary collapse
Methods inherited from PerNodeSyncer
Methods included from NodeAttrModule
Methods inherited from AbstractSyncer
#_fetch_html, #gen_html, #get_article_nodes, #initialize
Constructor Details
This class inherits a constructor from AbstractSyncer
Instance Method Details
#_handle_node(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/syncers/zhihu_syncer.rb', line 10 def _handle_node(node) if node.child and node.child["class"] == 'ztext-math' # write this line to your generated html for mathjax support: # <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> # for example, you can include it in your template file: _layouts/post.html node.content = '$$' + node.content + '$$' end case node.name when 'figure' img_node = node.css('img')[-1] if img_node node = img_node img_url = node['data-actualsrc'] img_url['/v2'] = '/80/v2' img_url = img_url.gsub(/_[a-zA-Z]\.jpg/, '_720w.jpg') # _[a-z].jpg -> _720.jpg node['src'] = img_url end end node.to_html end |
#get_article_xpath ⇒ Object
6 7 8 |
# File 'lib/syncers/zhihu_syncer.rb', line 6 def get_article_xpath '//div[contains(@class, "Post-RichText") and contains(@class, "ztext")]' end |