多级标签关闭 [英] multilevel tag closing

查看:84
本文介绍了多级标签关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多级标签关闭中遇到了问题,我想从内部级别关闭标签,然后再关闭其外部级别
< p_normal>< list-bull>
< p_list-bull(1)>使用Microsoft Windows辅助功能选项可以:
< p_list-simple(2)> –放大显示
< p_list-simple(2)> –更改文本和图标的大小
< p_list-simple(2)> –将显示的文本转换为语音(即讲述人)
< p_list-simple(2)> –更改对比度
< p_list-simple(2)> –显示屏幕键盘
< p_list-simple(2)> –将鼠标转换为左手使用.
< p_list-bull(1)>通过音频播客而不是为视障学习者提供书面讲义来提供学习.
< p_list-bull(1)>为视障学习者增加讲义上的字符大小.
< p_list-bull(1)>调整背景颜色和字体以帮助阅读困难的学习者.
我的输出应类似于以下代码

Hi,I''ve problem in multilevel tag closing,i want to close the tags form the inner level then come to close its outer level
<p_normal><list-bull>
<p_list-bull(1)>Use Microsoft Windows accessibility options to:
<p_list-simple(2)>– Magnify the display
<p_list-simple(2)>– Change the size of text and icons
<p_list-simple(2)>– Convert the text displayed into speech (i.e. narrator)
<p_list-simple(2)>– Change the contrast
<p_list-simple(2)>– Display an onscreen keyboard
<p_list-simple(2)>– Convert the mouse for left-handed use.
<p_list-bull(1)>Deliver learning through an audio podcast rather than written handouts for visually impaired learners.
<p_list-bull(1)>Increase the character size on handouts for visually impaired learners.
<p_list-bull(1)>Adjust background colours and fonts to assist dyslexic learners.
my output should be like the below code

<list list-type="bullet">
<list-item><p>Use Microsoft Windows accessibility options to:
<list list-type="simple">
<list-item><p>&#x2013; Magnify the display</p></list-item>
<list-item><p>&#x2013; Change the size of text and icons</p></list-item>
<list-item><p>&#x2013; Convert the text displayed into speech (i.e. narrator)</p></list-item>
<list-item><p>&#x2013; Change the contrast</p></list-item>
<list-item><p>&#x2013; Display an onscreen keyboard</p></list-item>
<list-item><p>&#x2013; Convert the mouse for left-handed use.</p></list-item>
</list></p></list-item>
<list-item><p>Deliver learning through an audio podcast rather than written handouts for visually impaired learners.</p></list-item>
<list-item><p>Increase the character size on handouts for visually impaired learners.</p></list-item>
<list-item><p>Adjust background colours and fonts to assist dyslexic learners.</p></list-item>
<list-item><p><xref ref-type="page" id="page_13"/>Provide feedback on written work using the comments facility and track changes rather than handwritten notes, so that the learners can change character size or use a text to speech application to hear feedback.</p></list-item>
</list>


我尝试了以下代码,但只给出了单个项目列表,不知道它的错误在哪里纠正了我的错误


i tried the below code but i gives single item list only i d''t know where its wrong pls correct my mistake

use strict;
my $inputfile = $ARGV[0];

open (IN,"$inputfile") || die ("Can't open the input file for reading");
undef $/;
my $str = <IN>;
 while($str =~ /<list-(bull)>(?:(?:(?!<\/list-bull>).)*)<\/list-\1>/sgi)
    {
    $str =~ s#<list-(bull)>(?:(?:(?!<\/list-bull>).)*)<\/list-\1>#&List_find($&)#sgie;

    }

sub List_find
{
my $line = @_[0];
my $currentlevel = 0;
while($line =~ /^[\s\S]*?<(P_list-(\w+)\((\d+)\))>(.*?)<\/\1>\s*/si)
{

    my ($tag, $kind, $level, $text) = ($1, $2, $3, $4);
    if ($currentlevel < $level) {
    while($currentlevel < $level) {
            $line = "\n<list list-type=\"$kind\">\n<list-item><p>";

            $currentlevel++;

        }

} elsif ($currentlevel > $level) {

        while($currentlevel > $level) {
            $currentlevel--;
            $line ="</p></list-item>\n</list>\n";
        }
        $line = "</p></list-item>\n<list-item><p>";

    } else {

       $line = "</p></list-item>\n<list-item><p>";

    }
        $line .= $text;

   # print $line;

}

while($currentlevel > 0) {
    $currentlevel--;
    $line .= "</p></list-item>\n</list>\n";
}



#print $line;
return "$line";
}
open (OUT,">$inputfile\.xml") || die ("Can't open the output file for writing");
print OUT $str;
close (OUT);  pls consider my problem

推荐答案

inputfile =
inputfile =


ARGV [0]; 打开(IN,"
ARGV[0]; open (IN,"


输入文件")||死(无法打开输入文件进行读取"); undef
inputfile") || die ("Can't open the input file for reading"); undef


这篇关于多级标签关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆