g0v / twangry

政誌 - Angry event made in Taiwan.
http://fact.g0v.tw
Do What The F*ck You Want To Public License
51 stars 25 forks source link

有 footnote 的句子會被斷尾 #24

Closed pm5 closed 11 years ago

pm5 commented 11 years ago

http://angry.g0v.tw/wiki/%E6%96%87%E6%9E%97%E8%8B%91%E9%83%BD%E5%B8%82%E6%9B%B4%E6%96%B0%E7%88%AD%E8%AD%B0#9

parse 出來是:

且與憲法所要求的比例原則及正當法律程序不符

原句是:

且與憲法所要求的比例原則及正當法律程序不符[79]。

pm5 commented 11 years ago

a patch:

    diff --git a/lib/zhdateparser.js b/lib/zhdateparser.js
    index b8d8e4b..b15b38b 100644
    --- a/lib/zhdateparser.js
    +++ b/lib/zhdateparser.js
    @@ -85,7 +85,7 @@ zhdateparser.parse = function(html){

       // Add placeholder to help tokenize
       html = html.replace(/((西元)?(\d\d{3}年?(-|-|~|~)\d\d{3}年)|\d\d{3}年)/g, "@@@$1"); // add placeholder for year
    -  html = html.replace(/(<\/sup>)/g, "$1`"); // add placeholder for year
    +  //html = html.replace(/(<\/sup>)/g, "$1`"); // add placeholder for year

       // Real parser
       // Phase 1: Find summary start at year, end with specific html tag

jimmy 可以說明一下 ` 這個 placeholder 是做什麼用的嗎?

jimyhuang commented 11 years ago

這是為了要在內文中,找出對應的外部索引,然後把索引提供給 timeline,timeline會自動針對外部的網頁做截圖

例如洪仲丘第一頁,因為找到索引,所以會去看他網頁,給timeline截圖 http://angry.g0v.tw/wiki/%E6%B4%AA%E4%BB%B2%E4%B8%98%E4%BA%8B%E4%BB%B6#1

json檔案中,「洪仲丘親生父親:仲丘跟他一起過父親節」的網址由此而來 http://angry.g0v.tw/wiki/%E6%B4%AA%E4%BB%B2%E4%B8%98%E4%BA%8B%E4%BB%B6.json

有更好的implement 方式,歡迎更改...

pm5 commented 11 years ago

改成 ((。|;)(<sup.*?<\/sup>)*) 後面放 placeholder @@@. 試了幾筆資料, 應該可以.

jimyhuang commented 11 years ago

pm5++++~ server已經apply code了~可以用這個來重抓json看看結果~ http://angry.g0v.tw/wiki/OOO.json?nocache=1

我抓了一下文林苑,看來是正確的 http://angry.g0v.tw/wiki/%E6%96%87%E6%9E%97%E8%8B%91%E9%83%BD%E5%B8%82%E6%9B%B4%E6%96%B0%E7%88%AD%E8%AD%B0.json?nocache=1