User:Midnite/Notes/Shell Script/Escape for Gentoo wiki

From Gentoo Wiki
Jump to:navigation Jump to:search

Handy shell scripts for escaping and formatting codes before posting to Gentoo wiki

Escape = to {{=}} and escape | to {{!!}}

f='script_file_name'
[ -f "$f" ] && { sed --expression 's/=/{{=}}/g' --expression 's/|/{{!!}}/g' "$f" > "$f".esc_eq_pipes ; } ; unset f

This is required for Block-level layout elements.


Note
===== {{!!}} versus {{!}} =====

Reference - Gentoo wiki : Template !! Documentation

  • {{!!}} means "I really want to see a pipe character!"
  • {{!}} means "Give me a pipe character that may be used as wiki markup, if necessary."


Note that this template does not work the same way as the Wikipedia template of the same name.


Prefix | on every line

f='script_file_name' ; [ -f "$f" ] && { sed --expression 's/^/|/' "$f" > "$f".line_prefix_pipe ; } ; unset f

This is suitable for Cmd and RootCmd which support multiple commands within one Block-level layout element.