_acs-tcl__ad_text_html_convert_to_plain (private)

 _acs-tcl__ad_text_html_convert_to_plain

Defined in packages/acs-tcl/tcl/test/html-conversion-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 _ _ (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_true aa_true (public) ad_html_text_convert ad_html_text_convert (public) _acs-tcl__ad_text_html_convert_to_plain _acs-tcl__ad_text_html_convert_to_plain _acs-tcl__ad_text_html_convert_to_plain->_ _acs-tcl__ad_text_html_convert_to_plain->aa_log _acs-tcl__ad_text_html_convert_to_plain->aa_log_result _acs-tcl__ad_text_html_convert_to_plain->aa_true _acs-tcl__ad_text_html_convert_to_plain->ad_html_text_convert

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{

    set html {<html><head><title>Some Title</title></head><body>
        <h1>An H1 Title</h1>
        <p>This is <b>bold</b> and this is <strong>strong</strong>.
        This is <i>italics</i> and this is <em>em</em>.
        A text with a <a href='/foo'>link</a>.
        </p>
        <h2>An H2 Title</h2>
        <p> Now the same with a blockquote:
        <blockquote>
        This is <b>bold</b> and this is <strong>strong</strong>.
        This is <i>italics</i> and this is <em>em</em>.
        A text with a <a href='/bar'>link</a>.
        </blockquote>
        Now a text with a ul:
        <ul>
        <li>First list item
        <li>Second list item
        </ul>
        Now a text with a ol:
        <ol>
        <li>First enumerated item
        <li>Second enumerated item
        </ol>

        and a program
        <pre>
        set x 1
        set r [expr {$x + 1}]
        </pre>
    }
    set result [ad_html_text_convert -from text/html -to text/plain $html]

    aa_log "Resulting text:\n$result"
    aa_true "Text contains title" [string match {Some Title*} $result]
    aa_true "<h1> and <h2> are detected and marked with stars" {
        [string first "\n*An H1" $result] > 0
        && [string first "\n**An H2" $result] > 0
    }
    aa_true "<b> and <strong> are converted" {
        [string first {*bold*} $result] > 0
        && [string first {*strong*} $result] > 0
    }
    aa_true "<i> and <em> are converted" {
        [string first {_italics_} $result] > 0
        && [string first {_em_} $result] > 0
    }
    aa_true "<ul> is converted" {
        [string first "\n- First list" $result] > 0
        && [string first "\n- Second list" $result] > 0
    }
    aa_true "<ol> is converted (same as <ul>)" {
        [string first "\n- First enumerated" $result] > 0
        && [string first "\n- Second enumerated" $result] > 0
    }

    aa_true "<pre> results in linebreaks and deeper indentation" {
        [string first "\n        set x" $result] > 0
        && [string first "\n        set r" $result] > 0
    }


    aa_true "Text contains two links" {
        [string first {[1].} $result] > 0
        && [string first {[2].} $result] > 0
    }
    aa_true "Text contains two references" {
        [string first {[1] /foo} $result] > 0
        && [string first {[2] /bar} $result] > 0
    }
    aa_true "Blockquote is indented" {
        [string first {    This is *bold} $result] > 0
    }

}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "ad_text_html_convert_to_plain (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: