diff --git a/qsgen2 b/qsgen2 index 7733d12..75385e1 100755 --- a/qsgen2 +++ b/qsgen2 @@ -797,107 +797,54 @@ function _cleanup() { } _html() { - local content="${1}" + local content="$1" local debug=false - if ${debug}; then _msg debug "_html: Converting QStags in content"; fi + if (${debug}) _msg debug "_html: Converting QStags in content" - # Define the Python code for parsing and replacing specific QStags - local python_code=$(cat <", - "#EH1": "", - "#H2": "

", - "#EH2": "

", - "#P": "

", - "#EP": "

", - "#BR": "
", - "#BD": "", - "#EBD": "", - "#I": "", - "#EI": "", - "#STRONG": "", - "#ESTRONG": "", - "#EM": "", - "#EM": "", - "#DIV": "
", - "#EDIV": "
", - "#SPAN": "", - "#ESPAN": "", - "#UL": "", - "#OL": "
    ", - "#EOL": "
", - "#LI": "
  • ", - "#ELI": "
  • ", - "#U": "", - "#EU": "", - "#TABLE": "", - "#ETABLE": "
    ", - "#TR": "", - "#ETR": "", - "#TD": "", - "#ETD": "", - "#TH": "", - "#ETH": "", - "#ART": "
    ", - "#EART": "
    ", - "#SEC": "
    ", - "#ESEC": "
    ", - "#ASIDE": "", - "#NAV": "", - "#BTN": "", - "#SEL": "", - "#OPT": "", - "#LT": "<", - "#GT": ">", - "#NUM": "#", - "#H1": "

    ", - "#H2": "

    ", - "#H3": "

    ", - "#H4": "

    ", - "#H5": "

    ", - "#H6": "
    ", - "#EH1": "
    ", - "#EH2": "", - "#EH3": "", - "#EH4": "", - "#EH5": "", - "#EH6": "", + perl -pe ' + BEGIN { + %qstags = ( + "#BR" => "
    \n", + "#BD" => "", "#EBD" => "\n", + "#I" => "", "#EI" => "\n", + "#P" => "

    ", "#EP" => "

    \n", + "#Q" => "
    ", "#EQ" => "
    \n", + "#C" => "", "#EC" => "\n", + "#H1" => "

    ", "#EH1" => "

    \n", + "#H2" => "

    ", "#EH2" => "

    \n", + "#H3" => "

    ", "#EH3" => "

    \n", + "#H4" => "

    ", "#EH4" => "

    \n", + "#H5" => "
    ", "#EH5" => "
    \n", + "#H6" => "
    ", "#EH6" => "
    \n", + "#STRONG" => "", "#ESTRONG" => "\n", + "#EM" => "", "#EEM" => "\n", + "#DV" => "
    ", "#EDV" => "
    \n", + "#SPN" => "", "#ESPN" => "\n", + "#UL" => "\n", + "#OL" => "
      ", "#EOL" => "
    \n", + "#LI" => "
  • ", "#ELI" => "
  • \n", + "#U" => "", "#EU" => "\n", + "#TBL" => "", "#ETBL" => "
    \n", + "#TR" => "", "#ETR" => "\n", + "#TD" => "", "#ETD" => "\n", + "#TH" => "", "#ETH" => "\n", + "#ART" => "
    ", "#EART" => "
    \n", + "#SEC" => "
    ", "#ESEC" => "
    \n", + "#ASIDE" => "\n", + "#NAV" => "\n", + "#BTN" => "\n", + "#SEL" => "\n", + "#OPT" => "\n", + "#LT" => "<", "#GT" => ">", "#NUM" => "#" + ); } - -# Define the regular expression pattern for QStags, excluding specific ones -pattern = r'(?<=\s)(#(?!link|image|ytvideo|updated|version)\w+)' - -# Replace QStags using the defined function -result = re.sub(pattern, replace_qstags, '''$content''', flags=re.MULTILINE) - -# Handle QStags at the beginning of lines separately -result = re.sub(r'^(#(?!link|image|ytvideo|updated|version)\w+)', replace_qstags, result, flags=re.MULTILINE) - -print(result) -EOF -) - - # Execute the Python code and capture the output - local html_content=$(python -c "${python_code}") - - echo "${html_content}" + while (my ($key, $value) = each %qstags) { + s/(?