Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.infosystems.www.authoring.html > #8075

Re: text to HTML

From ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups comp.infosystems.www.authoring.html, alt.html
Subject Re: text to HTML
Date 2026-09-11 18:07 +0000
Organization Stefan Ram
Message-ID <script-20260911190721@ram.dialup.fu-berlin.de> (permalink)
References <117u0ra$1tdh2$1@dont-email.me> <yoap1r4ofkkb.17tm3s9aihvuq.dlg@40tude.net>

Cross-posted to 2 groups.

Show all headers | View raw


JJ <jj4public@gmail.com> wrote or quoted:
>The basic idea and minimal method to convert text to HTML, is to replace all
>`<` characters with `&lt;`. Then insert `<pre>` at start of the text, and
>append `</pre>` at the end of the text.

  Yes. Here's a Python script that reads a text and prints HTML.

import html
code = html.escape( input( "Text? " ))
print( f"""
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xml:lang="en">
<head><meta charset="UTF-8" /><title>Web Page</title></head><body>
<pre>{code!s}</pre></body></html>
""" )

  Transcript

Text? <p>&amp;

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xml:lang="en">
<head><meta charset="UTF-8" /><title>Web Page</title></head><body>
<pre>&lt;p&gt;&amp;amp;</pre></body></html>

Newsgroups: comp.infosystems.www.authoring.html,alt.html

Back to comp.infosystems.www.authoring.html | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

text to HTML Dale <dalekellytoo@gmail.com> - 2026-09-10 06:30 -0400
  Re: text to HTML Michael Uplawski <michael.uplawski@uplawski.eu> - 2026-09-10 18:30 +0200
  Re: text to HTML JJ <jj4public@gmail.com> - 2026-09-11 11:10 +0700
    Re: text to HTML Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-11 07:03 +0000
    Re: text to HTML ram@zedat.fu-berlin.de (Stefan Ram) - 2026-09-11 18:07 +0000
  Re: text to HTML Helmut Richter <hr.usenet@email.de> - 2026-09-18 13:59 +0200

csiph-web