Add markdown support to Container Linux Feed (#730)
This commit is contained in:
parent
937ea49271
commit
5ea79ac1fc
1 changed files with 24 additions and 7 deletions
|
@ -40,18 +40,35 @@ class ContainerLinuxReleasesBridge extends BridgeAbstract {
|
||||||
|
|
||||||
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
||||||
$item['title'] = $releaseVersion;
|
$item['title'] = $releaseVersion;
|
||||||
$item['content'] = nl2br($release['release_notes']);
|
|
||||||
|
|
||||||
$item['content'] .= <<<EOT
|
$content = $release['release_notes'];
|
||||||
<br/>
|
$content .= <<<EOT
|
||||||
|
|
||||||
Major Software:
|
Major Software:
|
||||||
<br/>
|
* Kernel: {$release['major_software']['kernel'][0]}
|
||||||
- Kernel: {$release['major_software']['kernel'][0]}<br/>
|
* Docker: {$release['major_software']['docker'][0]}
|
||||||
- Docker: {$release['major_software']['docker'][0]}<br/>
|
* etcd: {$release['major_software']['etcd'][0]}
|
||||||
- etcd: {$release['major_software']['etcd'][0]}<br/>
|
|
||||||
EOT;
|
EOT;
|
||||||
$item['timestamp'] = strtotime($release['release_date']);
|
$item['timestamp'] = strtotime($release['release_date']);
|
||||||
|
|
||||||
|
// Based on https://gist.github.com/jbroadway/2836900
|
||||||
|
// Links
|
||||||
|
$regex = '/\[([^\[]+)\]\(([^\)]+)\)/';
|
||||||
|
$replacement = '<a href=\'\2\'>\1</a>';
|
||||||
|
$item['content'] = preg_replace($regex, $replacement, $content);
|
||||||
|
|
||||||
|
// Headings
|
||||||
|
$regex = '/^(.*)\:\s?$/m';
|
||||||
|
$replacement = '<h3>\1</h3>';
|
||||||
|
$item['content'] = preg_replace($regex, $replacement, $item['content']);
|
||||||
|
|
||||||
|
// Lists
|
||||||
|
$regex = '/\n\s*[\*|\-](.*)/';
|
||||||
|
$item['content'] = preg_replace_callback ($regex, function($regs) {
|
||||||
|
$item = $regs[1];
|
||||||
|
return sprintf ("<ul><li>%s</li></ul>", trim ($item));
|
||||||
|
}, $item['content']);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue