Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要转义非 HTML 标签才能将纯文本转换为有效的 HTML,我该怎么做?
我正在使用 ruby,但我可能会使用外部工具
您可以使用CGI::escapeHTML转义所有特殊的 HTML 字符,以便可以安全地将内容作为文本粘贴到 HTML 中。
CGI::escapeHTML