setext

来自「nedit 是一款linux下的开发源码的功能强大的编辑器」· 代码 · 共 1,890 行 · 第 1/5 页

TXT
1,890
字号
    $size = length( $_ );        #-------------------------------------------------    # Going to wrap titles with lines as long as title    #-------------------------------------------------    for( $size = length( $_ ); $size > 0; $size-- )    {        $line="$line$lc";    }    print CONVERT "$line\n$_\n$line\n";}sub text_underline_tt { replace_underlines( $underline_tt ) }#-------------------------------------------------------------------------------#                setext to HTML conversion call-back routines.#                         ( in alphabetical order )#-------------------------------------------------------------------------------sub html_bold_tt{    #---------------------------------------    # Turn all "**text**" into "<B>text</B>"    #---------------------------------------    s#$bold_tt#${lt}B${gt}$1${lt}/B${gt}$2#g;}#-------------------------------------------------------------------------------sub html_bullet_tt{    s/$bullet_tt(.*)/    ${lt}li${gt}$1$2${lt}\/li${gt}/;}#-------------------------------------------------------------------------------sub html_emit_footer{    print CONVERT "</P>\n$htmlFooter";    $closePgf = "";}#-------------------------------------------------------------------------------sub html_emit_header{    my $htitle = shift;    my $header = $htmlHeader;        $header =~ s/\$HTML_TITLE/$htitle/o;    print CONVERT $header;}#-------------------------------------------------------------------------------sub html_emit_line{    print CONVERT "<LI>" if $atListStart == 1 and not /${lt}LI${gt}/o;    $atListStart = 0;    if( /$passthru_tt/ )    {        s/$passthru_tt//o;  # remove typotag and pass line out as is.        reclaim_escapes();        print CONVERT "$_\n"    }    else    {        print CONVERT &html_finishing( $_ ), "\n";    }}#-------------------------------------------------------------------------------sub html_enter_list  { print CONVERT "<UL>\n"  }    # state change activitiessub html_leave_list  { print CONVERT "</UL>\n" }sub html_enter_pre   { print CONVERT "<PRE>\n";  $insideNoFormatArea = 1 }sub html_leave_pre   { print CONVERT "</PRE>\n"; $insideNoFormatArea = 0 }sub html_enter_quote { print CONVERT "<BLOCKQUOTE><PRE>\n";   $insideNoFormatArea = 1 }sub html_leave_quote { print CONVERT "</PRE></BLOCKQUOTE>\n"; $insideNoFormatArea = 0 }#-------------------------------------------------------------------------------sub html_final{    &to_state( $FMT );    html_emit_footer();    #----------------------------------------------------    # Report on all internal name references not used up.    #----------------------------------------------------    if( scalar( @nm_ref ) > 0 )    {        print STDERR "\nMissing reference (target-tt) to the following:\n\n";        for( $i=0; $i < scalar( @nm_ref ); $i++ )        {            print STDERR "  $nm_ref[ $i ]\n";        }    }}#-------------------------------------------------------------------------------sub html_finishing {    local($_) = @_;    my $unt;    s/\&/\&\#38\;/go; s/\</\&\#60\;/go; s/\>/\&\#62\;/go;    s/$lt/</go; s/$gt/>/go; s/$amp/\&/go;   # convert markers to real symbols    #-----------------------------------------------    # This fixes the case where an untouchable     # string includes these special html characters.    #-----------------------------------------------    foreach $element ( @untouchable )    {        $element =~ s/\&/\&\#38\;/go;        $element =~ s/\</\&\#60\;/go;        $element =~ s/\>/\&\#62\;/go;    }    recover_extractions();    $_;}#-------------------------------------------------------------------------------sub html_hot_tt{    #----------------------------------------------------    # After finding a hot-tt, substitute all underlines    # with spaces and check to see if the hot-tt had    # a corresponding hypertext reference. Flag it in    # bright, bold red when no hypertext record found.    # Allow user to define the variable HTML_DIR as the    # destination directory for the HTML code.     # Note, the files may have to actually be placed    # in such directory by hand after they are generated.    #----------------------------------------------------    s#$hot_tt#        $h = $href{$1}; ($text = $1) =~ s,_, ,go;        $h ? qq'${lt}A HREF="$variables{HTML_DIR}$h"${gt}$text${lt}/A${gt}'            : "${lt}B${gt}${lt}font color=red${gt}--> $text <-- NO HREF!!${lt}/font${gt}${lt}/B${gt}"; #eg;}#-------------------------------------------------------------------------------sub html_indent { s/$indent_tt/$1/ } # get rid of indent-tt characters#-------------------------------------------------------------------------------sub html_init{    local $title, $aTitle;    my    $target;        %state_change = (                enter_list  => "html_enter_list",        leave_list  => "html_leave_list",                enter_pre   => "html_enter_pre",        leave_pre   => "html_leave_pre",        enter_quote => "html_enter_quote",        leave_quote => "html_leave_quote",    );        $veryFirstTime = 1;   # used to force table of content header out    #------------------------------------------    # Make a first pass over the data, looking     # for hypertext linking information.    #------------------------------------------    for ($i = 0; $i <= $#data; $i++)     {        $_ = $data[$i];                 # $_ is default for searches        #---------------------------------------------------------        # This will pick out targets found in the setext not        # hidden by a suppress-tt, that is, the href-tt below.        # With this check, it is unnecessary to have to include        # the href-tt which uses identical text for internal        # document references. External references need href-tt.        # Have to make sure the match does not pick up elements        # inside a notouch-tt ( eg. `_do_not_want_this_as_target`)        #---------------------------------------------------------        if( /$target_tt/ && substr($`,length($`)-1,1) ne "`" &&             (not /$suppress_tt/) )        {            $href{ $4 } = "$intHrefMrk$4";            push @nm_ref, $4;        }                #-------------------------------------------------        # Locate HREF's and save. When no target is given,        # assume the target is internal, with same name.        #-------------------------------------------------        if( /$href_tt/  )        {            $hrefID = $1;            $target = ($2) ? $2 : "$intHrefMrk$hrefID"; # assume internal href.            $href{$hrefID} = $2;                             #------------------------------            # Remember internal HREF's not             # already seen for target-tt.            #------------------------------            if( $target =~ /$internal_href/ ) {                if( not is_member( substr( $target, 1), \@nm_ref ) ) {                    push @nm_ref, $1;                }            }            next;         }         #---------------------------------------------------------        # The first title-tt or subhead-tt gets <TITLE>...</TITLE>        #---------------------------------------------------------        /$title_tt/    && do { $htmlTitle = html_init_title("H1", $i); next; };        /$subtitle_tt/ && do { $htmlTitle = html_init_title("H2", $i); next; };    }    html_emit_header( $htmlTitle );        #----------------------------------------------------    # NOTE: changing original title-tt search pattern    #       to match what was done in html_init_title.    #----------------------------------------------------    $title_tt = "^\\.\\.\\s+(<H.>)(.*)(<\\/H.>)";}#-------------------------------------------------------------------------------sub html_init_title{    local($head, $i) = @_;    my $hyper_ref;        $data[$i--] = "..";      # suppress title indicator ( --- or === )    $data[$i]   =~ s/^\s*//; # get rid of any leading space in actual title    $this_title = $data[$i];        # Have to fix title if it also happens to be a target-tt.    $this_title =~ /$target_tt/ && do { ($tmp = $4) =~ s,_, ,go; $this_title = $tmp };        #---------------------------------------------------    # Are all titles automatically considered target-tt?    #---------------------------------------------------    if( $make_title_href )    {        $hyper_ref = $this_title;        $hyper_ref =~ s/ /_/go;        $externalReference  =           ($separate_html_files) ? substr("$MenuNames{ $hyper_ref }.$htmlExt", 1) : "";        $href{ $hyper_ref } ="$externalReference$intHrefMrk$hyper_ref";        #------------------------------        # Remember internal HREF's not         # already seen for target-tt.        #------------------------------        if( not is_member( $hyper_ref, \@nm_ref ) ) {            push @nm_ref, $hyper_ref;        }    }        #-----------------------------------------------------------------    # Put out the HTML title and then suppress it for later processing    #-----------------------------------------------------------------    $aTitle   = "$this_title" unless $title++;    $data[$i] = ".. <$head> " . $data[$i] . " </$head>";        return $aTitle;}#-------------------------------------------------------------------------------sub html_italic_tt{    #---------------------------------------    # Turn all "~text~" into "<I>text</I>"    #---------------------------------------    s#$italic_tt#${lt}I${gt}$1${lt}/I${gt}#g;}#-------------------------------------------------------------------------------sub html_line_break{    my $fold = shift;        print CONVERT "$closePgf<P>\n" unless $fold++;    $closePgf = "</P>";    return $fold;}#-------------------------------------------------------------------------------sub html_line_tt{    if( not $insideNoFormatArea )    {        s/$line_tt/${lt}P${gt}${lt}HR${gt}/;        print CONVERT html_finishing( $_ ), "\n";    }}#-------------------------------------------------------------------------------sub html_list_tt{    if( /$list_tt/o )    {        if ( $1 eq '(' ) # open list level        {            $list_level++;            s/$list_tt/${lt}UL${gt}${lt}LI${gt}/;        }        else             # close list level        {            $list_level--;            s,$list_tt,${lt}/LI${gt}${lt}/UL${gt},;            $atListStart = 2 if $list_level;            $terminatedList = 1;        }    }        #-----------------------------------------------------    # An empty line terminates a multiple line list entry.    #-----------------------------------------------------    elsif( /$empty_line/o )    {        print CONVERT "</LI>\n" unless $terminatedList;        print CONVERT "</P><P>\n";        $atListStart    = 1 if $list_level;        $terminatedList = 0;    }}#-------------------------------------------------------------------------------sub html_quote_tt{    s/$quote_tt\s*//;}#-------------------------------------------------------------------------------sub html_section_tt{    my $hdr_level = shift;        print CONVERT "<H$_</H$hdr_level>\n";}#-------------------------------------------------------------------------------sub html_target_tt{    check_target_reference( $_ );    /$target_tt/ && do { ($a = $4) =~ s,_, ,go; s/$target_tt/ $a/; };}#-------------------------------------------------------------------------------sub html_title{    my $titleHolder = $_;        to_state( $FMT );     /$target_tt/ && do { ($a = $4) =~ s,_, ,go; s/$target_tt/$a/; };        if( /$title_tt/i  ) # this is the new title-tt from html_init    {        $frontMrk = $1; $thisTitle = $2; $backMrk = $3;                if( not $separate_html_files or $veryFirs

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?