1
4

1 回答 1

0

如果没有解决方案,这是我编写的一个小 PHP 脚本,用于从必须在生成的 HTML 文件上运行的标题中删除标签:

<?php
// Usage: php cleanheadings.php myhtmlfile.html

// Check that arguments were supplied
if(!isset($argv[1])) die('No input file, exiting');

// Load file
$content = file_get_contents($argv[1]);

// Cut out the <a> tag
$heading = '/(<h[123456] id="[\w-0-9]+">)(<a href="#[\w-0-9]+">)(.+)(<\/a>)(<\/h[123456])/mu';
$clean   = '$1$3$5';

$cleanhtml = preg_replace($heading,$clean,$content);

// Write changes back to file
file_put_contents($argv[1], $cleanhtml);
?>
于 2013-05-11T12:03:55.527 回答