风の愿 » BACKEND

Yet Another PHP Markdown Parser Supports GFM

php-marked is a full-featured PHP markdown parser, completely ported from marked, brings you all excellent features of marked, including GFM.

It keep consistent with marked, which means you could safely implement fast or even realtime markdown previewing using client-side JavaScript and needn't worrying about inconsistent results between server-side rendering and client-side previewing.

  • Support Github Flavoured Markdown

    • Multiple underscores in words

    • URL autolinking

    • Strikethrough

    • Fenced code blocks

    • Tables

  • High performance

GitHub: https://github.com/breeswish/php-marked

Install via Composer:

composer install "breeswish/php-marked"
Published @ 08th July, 2014

Node.js 中使用 request 请求 GBK 页面

Node.js 有个很方便的 request 模块,提供了易于使用的接口向远程页面发起请求。然而,默认情况下它只能请求 UTF-8 的页面。

为了能让它请求 GBK 页面,还需要使用 iconv 模块转换字符集。

需要注意,request 的 encoding 参数必须设置为 null,否则它会先将其以字符串方式连接导致内容损坏。

Example:

var request = require('request');
var Iconv = require('iconv').Iconv;
var iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');

request.get({
    url: 'http://foo.bar',
    encoding: null
}, function(err, res, body) {
    console.log(iconv.convert(body).toString());
});

See also:

自动转换字符集

Published @ 10th August, 2013
1