2
我想寫一個Parsedown的擴展名,以便我可以爲每個表標記添加一個默認類。我發現,我可以成功地通過增加線路分配在blockTable
功能屬性(左右線870)破解的源代碼:如何擴展Parsedown以向表標記添加類
$Block = array(
'alignments' => $alignments,
'identified' => true,
'element' => array(
'name' => 'table',
'handler' => 'elements',
'attributes' => array(
'class' => 'table',
),
),
);
但是,如果我嘗試鬆散遵循Change Element Markup extension tutorial我是不成功的(也許。因爲表分析可能是一個反覆的過程,並在教程中的例子是一個簡單的字符串替換)
我已經試過:
class Extension extends Parsedown
{
protected function blockTable($Line, array $Block = null)
{
$Block = parent::blockTable($Line, array $Block = null);
$Block['table']['attributes']['class'] = 'table';
return $Block;
}
}
,但不起作用。
如果您正在尋求OP的更多信息,請使用註釋。 – Raju
我會,但我現在還不能評論。我盡力幫助,但我可以但不被網站允許。 – blakeaholics
這完全可以理解。它在元棧溢出上討論了很多次。一旦你有足夠的[聲譽](http://stackoverflow.com/help/whats-reputation),你將能夠[評論任何職位](http://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- I-DO-代替)。 – Raju