# File lib/asciidoctor/converter/manpage.rb, line 27
    def manify str, opts = {}
      str = ((opts.fetch :preserve_space, true) ? (str.gsub TAB, ET) : (str.tr_s WHITESPACE, ' ')).
        gsub(/(?:\A|[^#{ESC}])\\/, '\&(rs'). # literal backslash (not a troff escape sequence)
        gsub(/^\./, '\\\&.').     # leading . is used in troff for macro call or other formatting; replace with \&.
        # drop orphaned \c escape lines, unescape troff macro, quote adjacent character, isolate macro line
        gsub(/^(?:#{ESC}\\c\n)?#{ESC}\.((?:URL|MTO) ".*?" ".*?" )( |[^\s]*)(.*?)(?: *#{ESC}\\c)?$/) {
          (rest = $3.lstrip).empty? ? %(.#$1"#$2") : %(.#$1"#$2"#{LF}#{rest})
        }.
        gsub('-', '\-').
        gsub('&lt;', '<').
        gsub('&gt;', '>').
        gsub('&#160;', '\~').     # non-breaking space
        gsub('&#169;', '\(co').   # copyright sign
        gsub('&#174;', '\(rg').   # registered sign
        gsub('&#8482;', '\(tm').  # trademark sign
        gsub('&#8201;', ' ').     # thin space
        gsub('&#8211;', '\(en').  # en dash
        gsub(/&#8212(?:;&#8203;)?/, '\(em'). # em dash
        gsub('&#8216;', '\(oq').  # left single quotation mark
        gsub('&#8217;', '\(cq').  # right single quotation mark
        gsub('&#8220;', '\(lq').  # left double quotation mark
        gsub('&#8221;', '\(rq').  # right double quotation mark
        gsub(/&#8230;(?:&#8203;)?/, '...'). # horizontal ellipsis
        gsub('&#8592;', '\(<-').  # leftwards arrow
        gsub('&#8594;', '\(->').  # rightwards arrow
        gsub('&#8656;', '\(lA').  # leftwards double arrow
        gsub('&#8658;', '\(rA').  # rightwards double arrow
        gsub('&#8203;', '\:').    # zero width space
        gsub('\'', '\(aq').       # apostrophe-quote
        gsub(/<\/?BOUNDARY>/, '').# artificial boundary
        gsub(ESC_BS, '\\').       # unescape troff backslash (NOTE update if more escaped are added)
        rstrip                    # strip trailing space
      opts[:append_newline] ? %(#{str}#{LF}) : str
    end